From fba46ae074025cb605d46be9b1080e0649635dd6 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 16 Dec 2011 10:39:47 +1030 Subject: [PATCH] opt: handle -Wcast-qual warnings. --- ccan/opt/_info | 3 ++- ccan/opt/helpers.c | 3 ++- ccan/opt/private.h | 2 +- ccan/opt/test/run-helpers.c | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ccan/opt/_info b/ccan/opt/_info index afd6e19b..9595a168 100644 --- a/ccan/opt/_info +++ b/ccan/opt/_info @@ -61,8 +61,9 @@ int main(int argc, char *argv[]) return 1; if (strcmp(argv[1], "depends") == 0) { - printf("ccan/typesafe_cb\n"); + printf("ccan/cast\n"); printf("ccan/compiler\n"); + printf("ccan/typesafe_cb\n"); return 0; } diff --git a/ccan/opt/helpers.c b/ccan/opt/helpers.c index 17d56e02..e7ab273c 100644 --- a/ccan/opt/helpers.c +++ b/ccan/opt/helpers.c @@ -1,5 +1,6 @@ /* Licensed under GPLv3+ - see LICENSE file for details */ #include +#include #include #include #include @@ -52,7 +53,7 @@ char *opt_set_invbool_arg(const char *arg, bool *b) /* Set a char *. */ char *opt_set_charp(const char *arg, char **p) { - *p = (char *)arg; + *p = cast_const(char *, arg); return NULL; } diff --git a/ccan/opt/private.h b/ccan/opt/private.h index e4ad24a2..12c56931 100644 --- a/ccan/opt/private.h +++ b/ccan/opt/private.h @@ -7,7 +7,7 @@ extern unsigned int opt_count, opt_num_short, opt_num_short_arg, opt_num_long; extern const char *opt_argv0; -#define subtable_of(entry) ((struct opt_table *)((entry)->names)) +#define subtable_of(entry) ((const struct opt_table *)((entry)->names)) const char *first_sopt(unsigned *i); const char *next_sopt(const char *names, unsigned *i); diff --git a/ccan/opt/test/run-helpers.c b/ccan/opt/test/run-helpers.c index f85c73c4..de60ac9f 100644 --- a/ccan/opt/test/run-helpers.c +++ b/ccan/opt/test/run-helpers.c @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) } /* opt_set_charp */ { - char *arg = (char *)"wrong"; + char *arg = cast_const(char *, "wrong"); reset_options(); opt_register_arg("-a", opt_set_charp, NULL, &arg, "All"); ok1(parse_args(&argc, &argv, "-a", "string", NULL)); -- 2.39.2