From 506e082b551ea2d337d68d8a929bdacfb7e77f95 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 22 May 2014 23:18:40 +0000 Subject: list: fix -Wcast-qual warnings 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 --- ccan/list/list.c | 11 ++++++----- ccan/list/list.h | 10 ++++++---- 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 +#include #include #include #include @@ -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 */ -- cgit v1.2.3-24-ge0c7