Browse Source

opt: handle -Wcast-qual warnings.

Rusty Russell 14 years ago
parent
commit
fba46ae074
4 changed files with 6 additions and 4 deletions
  1. 2 1
      ccan/opt/_info
  2. 2 1
      ccan/opt/helpers.c
  3. 1 1
      ccan/opt/private.h
  4. 1 1
      ccan/opt/test/run-helpers.c

+ 2 - 1
ccan/opt/_info

@@ -61,8 +61,9 @@ int main(int argc, char *argv[])
 		return 1;
 		return 1;
 
 
 	if (strcmp(argv[1], "depends") == 0) {
 	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;
 	}
 	}
 
 

+ 2 - 1
ccan/opt/helpers.c

@@ -1,5 +1,6 @@
 /* Licensed under GPLv3+ - see LICENSE file for details */
 /* Licensed under GPLv3+ - see LICENSE file for details */
 #include <ccan/opt/opt.h>
 #include <ccan/opt/opt.h>
+#include <ccan/cast/cast.h>
 #include <string.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <errno.h>
@@ -52,7 +53,7 @@ char *opt_set_invbool_arg(const char *arg, bool *b)
 /* Set a char *. */
 /* Set a char *. */
 char *opt_set_charp(const char *arg, char **p)
 char *opt_set_charp(const char *arg, char **p)
 {
 {
-	*p = (char *)arg;
+	*p = cast_const(char *, arg);
 	return NULL;
 	return NULL;
 }
 }
 
 

+ 1 - 1
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;
 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 *first_sopt(unsigned *i);
 const char *next_sopt(const char *names, unsigned *i);
 const char *next_sopt(const char *names, unsigned *i);

+ 1 - 1
ccan/opt/test/run-helpers.c

@@ -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();
 		reset_options();
 		opt_register_arg("-a", opt_set_charp, NULL, &arg, "All");
 		opt_register_arg("-a", opt_set_charp, NULL, &arg, "All");
 		ok1(parse_args(&argc, &argv, "-a", "string", NULL));
 		ok1(parse_args(&argc, &argv, "-a", "string", NULL));