about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2014-05-22 23:18:40 +0000
committerEric Wong <e@80x24.org>2014-05-22 23:46:53 +0000
commit506e082b551ea2d337d68d8a929bdacfb7e77f95 (patch)
tree9ea391a7fd739f2023095519b252e5a8ef24beb2
parent489e29e887f58eca37a5fefa205ff91a1c772f3c (diff)
downloadcmogstored-506e082b551ea2d337d68d8a929bdacfb7e77f95.tar.gz
These warnings were encountered when adding ccan/list to cmogstored
(which uses -Wcast-qual).  This changes the public API for checking,
but I doubt anybody is affected.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
-rw-r--r--ccan/list/list.c11
-rw-r--r--ccan/list/list.h10
2 files changed, 12 insertions, 9 deletions
diff --git a/ccan/list/list.c b/ccan/list/list.c
index 2717fa3..ba8e191 100644
--- a/ccan/list/list.c
+++ b/ccan/list/list.c
@@ -17,8 +17,8 @@ static void *corrupt(const char *abortstr,
         return NULL;
 }
 
-struct list_node *list_check_node(const struct list_node *node,
-                                  const char *abortstr)
+const struct list_node *list_check_node(const struct list_node *node,
+                                        const char *abortstr)
 {
         const struct list_node *p, *n;
         int count = 0;
@@ -32,12 +32,13 @@ struct list_node *list_check_node(const struct list_node *node,
         if (node->prev != p)
                 return corrupt(abortstr, node, node, 0);
 
-        return (struct list_node *)node;
+        return node;
 }
 
-struct list_head *list_check(const struct list_head *h, const char *abortstr)
+const struct list_head *list_check(const struct list_head *h,
+                                const char *abortstr)
 {
         if (!list_check_node(&h->n, abortstr))
                 return NULL;
-        return (struct list_head *)h;
+        return h;
 }
diff --git a/ccan/list/list.h b/ccan/list/list.h
index 4d1d34e..99dfbd2 100644
--- a/ccan/list/list.h
+++ b/ccan/list/list.h
@@ -3,6 +3,7 @@
 #define CCAN_LIST_H
 //#define CCAN_LIST_DEBUG 1
 #include <stdbool.h>
+#include <stdint.h>
 #include <assert.h>
 #include <ccan/str/str.h>
 #include <ccan/container_of/container_of.h>
@@ -69,7 +70,8 @@ struct list_head
  *                        printf(" -> %s\n", c->name);
  *        }
  */
-struct list_head *list_check(const struct list_head *h, const char *abortstr);
+const struct list_head *list_check(const struct list_head *h,
+                                const char *abortstr);
 
 /**
  * list_check_node - check node of a list for consistency
@@ -87,8 +89,8 @@ struct list_head *list_check(const struct list_head *h, const char *abortstr);
  *                printf("%s\n", c->name);
  *        }
  */
-struct list_node *list_check_node(const struct list_node *n,
-                                  const char *abortstr);
+const struct list_node *list_check_node(const struct list_node *n,
+                                        const char *abortstr);
 
 #define LIST_LOC __FILE__  ":" stringify(__LINE__)
 #ifdef CCAN_LIST_DEBUG
@@ -651,6 +653,6 @@ static inline void *list_entry_or_null(const struct list_head *h,
 {
         if (n == &h->n)
                 return NULL;
-        return (char *)n - off;
+        return (void *)((uintptr_t)n - off);
 }
 #endif /* CCAN_LIST_H */