]> git.ozlabs.org Git - ccan/commitdiff
opt: handle -Wcast-qual warnings.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 16 Dec 2011 00:09:47 +0000 (10:39 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 16 Dec 2011 00:09:47 +0000 (10:39 +1030)
ccan/opt/_info
ccan/opt/helpers.c
ccan/opt/private.h
ccan/opt/test/run-helpers.c

index afd6e19b1551fa7522567ef4954eb272cde44498..9595a168f7e90b6ae5936029c630941721cff21e 100644 (file)
@@ -61,8 +61,9 @@ int main(int argc, char *argv[])
                return 1;
 
        if (strcmp(argv[1], "depends") == 0) {
                return 1;
 
        if (strcmp(argv[1], "depends") == 0) {
-               printf("ccan/typesafe_cb\n");
+               printf("ccan/cast\n");
                printf("ccan/compiler\n");
                printf("ccan/compiler\n");
+               printf("ccan/typesafe_cb\n");
                return 0;
        }
 
                return 0;
        }
 
index 17d56e0201dc66d7810b26f1cd40a1e5e702f0a7..e7ab273cdcede67a9bec9ae868ec8d8faa84cd6b 100644 (file)
@@ -1,5 +1,6 @@
 /* Licensed under GPLv3+ - see LICENSE file for details */
 #include <ccan/opt/opt.h>
 /* Licensed under GPLv3+ - see LICENSE file for details */
 #include <ccan/opt/opt.h>
+#include <ccan/cast/cast.h>
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -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)
 {
 /* Set a char *. */
 char *opt_set_charp(const char *arg, char **p)
 {
-       *p = (char *)arg;
+       *p = cast_const(char *, arg);
        return NULL;
 }
 
        return NULL;
 }
 
index e4ad24a2be9e7947f862d295bef76b330c735c90..12c569311b4a62d880981323de1eac82aff8ca77 100644 (file)
@@ -7,7 +7,7 @@ extern unsigned int opt_count, opt_num_short, opt_num_short_arg, opt_num_long;
 
 extern const char *opt_argv0;
 
 
 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);
 
 const char *first_sopt(unsigned *i);
 const char *next_sopt(const char *names, unsigned *i);
index f85c73c4e9f10ad8e2d8e8ea9c8c4a5d2f25dfff..de60ac9ff08e4fbac8e46943fe36e404f2301361 100644 (file)
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
        }
        /* opt_set_charp */
        {
        }
        /* 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));
                reset_options();
                opt_register_arg("-a", opt_set_charp, NULL, &arg, "All");
                ok1(parse_args(&argc, &argv, "-a", "string", NULL));