From 2fc852dcbd96a3e80b2d2b660980b263759c9f16 Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh Date: Tue, 24 Jul 2018 01:41:59 +0800 Subject: [PATCH] fix warnings on const char * discards qualifiers --- cstool/cstool.c | 2 +- cstool/cstool_evm.c | 1 - cstool/cstool_m680x.c | 6 +++--- cstool/cstool_tms320c64x.c | 2 +- cstool/cstool_x86.c | 6 +++--- cstool/getopt.h | 4 ++-- tests/test_arm.c | 4 ++-- tests/test_arm64.c | 4 ++-- tests/test_basic.c | 4 ++-- tests/test_detail.c | 2 +- tests/test_evm.c | 4 ++-- tests/test_iter.c | 2 +- tests/test_m680x.c | 12 ++++++------ tests/test_m68k.c | 4 ++-- tests/test_mips.c | 4 ++-- tests/test_ppc.c | 4 ++-- tests/test_skipdata.c | 2 +- tests/test_sparc.c | 4 ++-- tests/test_systemz.c | 4 ++-- tests/test_tms320c64x.c | 4 ++-- tests/test_x86.c | 6 +++--- tests/test_xcore.c | 4 ++-- 22 files changed, 44 insertions(+), 45 deletions(-) diff --git a/cstool/cstool.c b/cstool/cstool.c index cd3483ec..65ad945d 100644 --- a/cstool/cstool.c +++ b/cstool/cstool.c @@ -74,7 +74,7 @@ void print_insn_detail_evm(csh handle, cs_insn *ins); static void print_details(csh handle, cs_arch arch, cs_mode md, cs_insn *ins); -void print_string_hex(char *comment, unsigned char *str, size_t len) +void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/cstool/cstool_evm.c b/cstool/cstool_evm.c index 18b31920..692a3f0a 100644 --- a/cstool/cstool_evm.c +++ b/cstool/cstool_evm.c @@ -8,7 +8,6 @@ void print_string_hex(char *comment, unsigned char *str, size_t len); void print_insn_detail_evm(csh handle, cs_insn *ins) { cs_evm *evm; - int i; // detail can be NULL on "data" instruction if SKIPDATA option is turned ON if (ins->detail == NULL) diff --git a/cstool/cstool_m680x.c b/cstool/cstool_m680x.c index 84130515..4a9a5192 100644 --- a/cstool/cstool_m680x.c +++ b/cstool/cstool_m680x.c @@ -60,7 +60,7 @@ void print_insn_detail_m680x(csh handle, cs_insn *insn) for (i = 0; i < m680x->op_count; i++) { cs_m680x_op *op = &(m680x->operands[i]); - char *comment; + const char *comment; switch ((int)op->type) { default: @@ -131,9 +131,9 @@ void print_insn_detail_m680x(csh handle, cs_insn *insn) } if (op->idx.inc_dec) { - char *post_pre = op->idx.flags & + const char *post_pre = op->idx.flags & M680X_IDX_POST_INC_DEC ? "post" : "pre"; - char *inc_dec = (op->idx.inc_dec > 0) ? + const char *inc_dec = (op->idx.inc_dec > 0) ? "increment" : "decrement"; printf("\t\t\t%s %s: %d\n", post_pre, inc_dec, diff --git a/cstool/cstool_tms320c64x.c b/cstool/cstool_tms320c64x.c index 882a6a52..daede36a 100644 --- a/cstool/cstool_tms320c64x.c +++ b/cstool/cstool_tms320c64x.c @@ -4,7 +4,7 @@ #include #include -void print_string_hex(char *comment, unsigned char *str, size_t len); +void print_string_hex(const char *comment, unsigned char *str, size_t len); void print_insn_detail_tms320c64x(csh handle, cs_insn *ins) { diff --git a/cstool/cstool_x86.c b/cstool/cstool_x86.c index f5d2bab9..ff3be36f 100644 --- a/cstool/cstool_x86.c +++ b/cstool/cstool_x86.c @@ -5,9 +5,9 @@ #include -void print_string_hex(char *comment, unsigned char *str, size_t len); +void print_string_hex(const char *comment, unsigned char *str, size_t len); -static char *get_eflag_name(uint64_t flag) +static const char *get_eflag_name(uint64_t flag) { switch(flag) { default: @@ -129,7 +129,7 @@ static char *get_eflag_name(uint64_t flag) } } -static char *get_fpu_flag_name(uint64_t flag) +static const char *get_fpu_flag_name(uint64_t flag) { switch (flag) { default: diff --git a/cstool/getopt.h b/cstool/getopt.h index 210ac9f4..81af4105 100644 --- a/cstool/getopt.h +++ b/cstool/getopt.h @@ -6,7 +6,7 @@ int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ optopt, /* character checked for validity */ optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ +const char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define BADARG (int)':' @@ -19,7 +19,7 @@ char *optarg; /* argument associated with option */ int getopt (int nargc, char * const nargv[], const char *ostr) { - static char *place = EMSG; /* option letter processing */ + static const char *place = EMSG; /* option letter processing */ const char *oli; /* option letter list index */ if (optreset || !*place) { /* update scanning pointer */ diff --git a/tests/test_arm.c b/tests/test_arm.c index d021dff8..eedcc98e 100644 --- a/tests/test_arm.c +++ b/tests/test_arm.c @@ -14,11 +14,11 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; int syntax; }; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_arm64.c b/tests/test_arm64.c index fc8f7e68..951f7d2a 100644 --- a/tests/test_arm64.c +++ b/tests/test_arm64.c @@ -14,10 +14,10 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_basic.c b/tests/test_basic.c index 56dbd2f4..22ea2e41 100644 --- a/tests/test_basic.c +++ b/tests/test_basic.c @@ -12,7 +12,7 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; cs_opt_type opt_type; cs_opt_value opt_value; }; @@ -91,7 +91,7 @@ static void test() cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; cs_opt_type opt_type; cs_opt_value opt_value; }; diff --git a/tests/test_detail.c b/tests/test_detail.c index 48af3b97..c4c61dd5 100644 --- a/tests/test_detail.c +++ b/tests/test_detail.c @@ -12,7 +12,7 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; cs_opt_type opt_type; cs_opt_value opt_value; }; diff --git a/tests/test_evm.c b/tests/test_evm.c index 1d1d88a8..1b21f27e 100644 --- a/tests/test_evm.c +++ b/tests/test_evm.c @@ -14,10 +14,10 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_iter.c b/tests/test_iter.c index 6c9169b7..5ad9d3e9 100644 --- a/tests/test_iter.c +++ b/tests/test_iter.c @@ -13,7 +13,7 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; cs_opt_type opt_type; cs_opt_value opt_value; }; diff --git a/tests/test_m680x.c b/tests/test_m680x.c index 708bcdfc..666161c5 100644 --- a/tests/test_m680x.c +++ b/tests/test_m680x.c @@ -16,10 +16,10 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; @@ -85,7 +85,7 @@ static void print_insn_detail(csh handle, cs_insn *insn) for (i = 0; i < m680x->op_count; i++) { cs_m680x_op *op = &(m680x->operands[i]); - char *comment; + const char *comment; switch ((int)op->type) { default: @@ -157,9 +157,9 @@ static void print_insn_detail(csh handle, cs_insn *insn) } if (op->idx.inc_dec) { - char *post_pre = op->idx.flags & + const char *post_pre = op->idx.flags & M680X_IDX_POST_INC_DEC ? "post" : "pre"; - char *inc_dec = (op->idx.inc_dec > 0) ? + const char *inc_dec = (op->idx.inc_dec > 0) ? "increment" : "decrement"; printf("\t\t\t%s %s: %d\n", post_pre, inc_dec, @@ -328,7 +328,7 @@ static void test() cs_insn *insn; int i; size_t count; - char *nine_spaces = " "; + const char *nine_spaces = " "; if (!consistency_checks()) abort(); diff --git a/tests/test_m68k.c b/tests/test_m68k.c index cc5f7864..62b05be0 100644 --- a/tests/test_m68k.c +++ b/tests/test_m68k.c @@ -11,12 +11,12 @@ struct platform { cs_mode mode; unsigned char* code; size_t size; - char* comment; + const char* comment; }; static csh handle; -static void print_string_hex(char* comment, unsigned char* str, size_t len) +static void print_string_hex(const char* comment, unsigned char* str, size_t len) { unsigned char *c; diff --git a/tests/test_mips.c b/tests/test_mips.c index d3864bd3..5645a48b 100644 --- a/tests/test_mips.c +++ b/tests/test_mips.c @@ -12,12 +12,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; static csh handle; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_ppc.c b/tests/test_ppc.c index 0ad5de38..f0eceea7 100644 --- a/tests/test_ppc.c +++ b/tests/test_ppc.c @@ -11,12 +11,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; static csh handle; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_skipdata.c b/tests/test_skipdata.c index 5217210f..e27798b3 100644 --- a/tests/test_skipdata.c +++ b/tests/test_skipdata.c @@ -12,7 +12,7 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; cs_opt_type opt_type; cs_opt_value opt_value; cs_opt_type opt_skipdata; diff --git a/tests/test_sparc.c b/tests/test_sparc.c index 122829a5..369e0777 100644 --- a/tests/test_sparc.c +++ b/tests/test_sparc.c @@ -11,12 +11,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; static csh handle; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_systemz.c b/tests/test_systemz.c index ec1af9dd..6bdcc6f4 100644 --- a/tests/test_systemz.c +++ b/tests/test_systemz.c @@ -11,12 +11,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; static csh handle; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_tms320c64x.c b/tests/test_tms320c64x.c index 3dee537e..86a6d76d 100644 --- a/tests/test_tms320c64x.c +++ b/tests/test_tms320c64x.c @@ -10,12 +10,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; static csh handle; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; diff --git a/tests/test_x86.c b/tests/test_x86.c index 1fa1b136..ebabf184 100644 --- a/tests/test_x86.c +++ b/tests/test_x86.c @@ -14,12 +14,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; cs_opt_type opt_type; cs_opt_value opt_value; }; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c; @@ -31,7 +31,7 @@ static void print_string_hex(char *comment, unsigned char *str, size_t len) printf("\n"); } -static char *get_eflag_name(uint64_t flag) +static const char *get_eflag_name(uint64_t flag) { switch(flag) { default: diff --git a/tests/test_xcore.c b/tests/test_xcore.c index b382ef6b..12cc1f1b 100644 --- a/tests/test_xcore.c +++ b/tests/test_xcore.c @@ -11,12 +11,12 @@ struct platform { cs_mode mode; unsigned char *code; size_t size; - char *comment; + const char *comment; }; static csh handle; -static void print_string_hex(char *comment, unsigned char *str, size_t len) +static void print_string_hex(const char *comment, unsigned char *str, size_t len) { unsigned char *c;