From e377ca52199a29a8502389c4d29d8517903b7f2f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 12 Apr 2010 16:00:44 +0000 Subject: [PATCH] sim: constify dup_arg_p The dup_arg_p function is only given const strings, and it maintains a local table of those const strings. So constify the whole thing to fix the GCC warnings: common/sim-options.c: In function 'sim_parse_args': common/sim-options.c:559: warning: passing argument 1 of 'dup_arg_p' discards qualifiers from pointer target type common/sim-options.c: In function 'print_help': common/sim-options.c:675: warning: passing argument 1 of 'dup_arg_p' discards qualifiers from pointer target type Signed-off-by: Mike Frysinger --- sim/common/ChangeLog | 5 +++++ sim/common/sim-options.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 1fef069935b..1bf564af84c 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,8 @@ +2010-04-12 Mike Frysinger + + * sim-options.c (dup_arg_p): Add "const" to the "arg" argument, + the local "arg_table" variable, and the xmalloc cast. + 2010-04-10 Mike Frysinger * sim-fpu.c (sim_fpu_print_status): Add const markings to local diff --git a/sim/common/sim-options.c b/sim/common/sim-options.c index a37dca9a4cc..02ad40e60b5 100644 --- a/sim/common/sim-options.c +++ b/sim/common/sim-options.c @@ -489,15 +489,15 @@ standard_install (SIM_DESC sd) #define ARG_HASH(a) ((256 * (unsigned char) a[0] + (unsigned char) a[1]) % ARG_HASH_SIZE) static int -dup_arg_p (char *arg) +dup_arg_p (const char *arg) { int hash; - static char **arg_table = NULL; + static const char **arg_table = NULL; if (arg == NULL) { if (arg_table == NULL) - arg_table = (char **) xmalloc (ARG_HASH_SIZE * sizeof (char *)); + arg_table = (const char **) xmalloc (ARG_HASH_SIZE * sizeof (char *)); memset (arg_table, 0, ARG_HASH_SIZE * sizeof (char *)); return 0; } -- 2.30.2