]> git.ozlabs.org Git - ccan/commitdiff
str: fix warnings.
authorRusty Russell <rusty@rustcorp.com.au>
Mon, 26 Sep 2011 10:43:07 +0000 (20:13 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Mon, 26 Sep 2011 10:43:07 +0000 (20:13 +0930)
Firstly, -Wwrite-strings makes string literals const, secondly, we mustn't
define str_strstr etc in terms of themselves!

ccan/str/debug.c
ccan/str/test/run.c

index 9ef756766aa557b61e1ab4abeaaceba71900beaf..027915bc640cf091b9c9e2b58b00f68b80f1c583 100644 (file)
@@ -86,6 +86,9 @@ int str_isxdigit(int i)
        return isxdigit(i);
 }
 
+#undef strstr
+#undef strchr
+#undef strrchr
 
 char *str_strstr(const char *haystack, const char *needle)
 {
index 3ccadbe5df89c17ad6c1487657e0e5e032108eb8..0f00ea320d2a67fbc8c65448f14017abbdb1a165 100644 (file)
@@ -6,7 +6,8 @@
 
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
 
-static char *substrings[] = { "far", "bar", "baz", "b", "ba", "z", "ar", NULL };
+static const char *substrings[] = { "far", "bar", "baz", "b", "ba", "z", "ar",
+                                   NULL };
 
 #define NUM_SUBSTRINGS (ARRAY_SIZE(substrings) - 1)