do not initialize some local vars unnecessarily. this problem was introduced when we fixed C89 issues for MSVC
diff --git a/cs.c b/cs.c
index a2db926..35264f4 100644
--- a/cs.c
+++ b/cs.c
@@ -129,7 +129,7 @@
cs_err cs_errno(csh handle)
{
- struct cs_struct *ud = NULL;
+ struct cs_struct *ud;
if (!handle)
return CS_ERR_CSH;
@@ -173,7 +173,7 @@
cs_err cs_open(cs_arch arch, cs_mode mode, csh *handle)
{
cs_err err;
- struct cs_struct *ud = NULL;
+ struct cs_struct *ud;
if (!cs_mem_malloc || !cs_mem_calloc || !cs_mem_realloc || !cs_mem_free || !cs_vsnprintf)
// Error: before cs_open(), dynamic memory management must be initialized
// with cs_option(CS_OPT_MEM)
@@ -216,7 +216,8 @@
cs_err cs_close(csh *handle)
{
- struct cs_struct *ud = NULL;
+ struct cs_struct *ud;
+
if (*handle == 0)
// invalid handle
return CS_ERR_CSH;
@@ -243,7 +244,8 @@
static void fill_insn(struct cs_struct *handle, cs_insn *insn, char *buffer, MCInst *mci,
PostPrinter_t postprinter, const uint8_t *code)
{
- char *sp = NULL;
+ char *sp;
+
if (handle->detail) {
// avoiding copy insn->detail
memcpy(insn, &mci->flat_insn, sizeof(*insn) - sizeof(insn->detail));
@@ -334,7 +336,7 @@
cs_err cs_option(csh ud, cs_opt_type type, size_t value)
{
- struct cs_struct *handle = NULL;
+ struct cs_struct *handle;
archs_enable();
// cs_option() can be called with NULL handle just for CS_OPT_MEM
@@ -605,7 +607,7 @@
bool cs_insn_group(csh ud, cs_insn *insn, unsigned int group_id)
{
- struct cs_struct *handle = NULL;
+ struct cs_struct *handle;
if (!ud)
return false;
@@ -631,7 +633,7 @@
bool cs_reg_read(csh ud, cs_insn *insn, unsigned int reg_id)
{
- struct cs_struct *handle = NULL;
+ struct cs_struct *handle;
if (!ud)
return false;
@@ -657,7 +659,7 @@
bool cs_reg_write(csh ud, cs_insn *insn, unsigned int reg_id)
{
- struct cs_struct *handle = NULL;
+ struct cs_struct *handle;
if (!ud)
return false;
@@ -683,8 +685,8 @@
int cs_op_count(csh ud, cs_insn *insn, unsigned int op_type)
{
- struct cs_struct *handle = NULL;
- unsigned int count = 0, i = 0;
+ struct cs_struct *handle;
+ unsigned int count = 0, i;
if (!ud)
return -1;
@@ -754,8 +756,8 @@
int cs_op_index(csh ud, cs_insn *insn, unsigned int op_type,
unsigned int post)
{
- struct cs_struct *handle = NULL;
- unsigned int count = 0, i = 0;
+ struct cs_struct *handle;
+ unsigned int count = 0, i;
if (!ud)
return -1;