Skip to content

Commit

Permalink
fix warnings on const char * discards qualifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
aquynh committed Jul 23, 2018
1 parent 443f82e commit 2fc852d
Show file tree
Hide file tree
Showing 22 changed files with 44 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cstool/cstool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 0 additions & 1 deletion cstool/cstool_evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cstool/cstool_m680x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cstool/cstool_tms320c64x.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stdio.h>
#include <capstone/capstone.h>

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)
{
Expand Down
6 changes: 3 additions & 3 deletions cstool/cstool_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include <capstone/capstone.h>

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:
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions cstool/getopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)':'
Expand All @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions tests/test_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_arm64.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/test_detail.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions tests/test_evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/test_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
12 changes: 6 additions & 6 deletions tests/test_m680x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/test_m68k.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_ppc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/test_skipdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sparc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_systemz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions tests/test_tms320c64x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions tests/test_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_xcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2fc852d

Please sign in to comment.