[ccan] [PATCH] list: fix -Wcast-qual warnings
Eric Wong
normalperson at yhbt.net
Fri May 23 09:43:38 EST 2014
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 at yhbt.net>
---
The following changes since commit ebc67c3fc630b8c7e71880c4972f5f8cde3b9a53:
bitmap: Use const qualifiers where possible (2014-05-19 21:21:48 +1000)
are available in the git repository at:
git://bogomips.org/ccan list-wcast-qual
for you to fetch changes up to ab8e8217a5111f1ba65a3e548f9bba345f585298:
list: fix -Wcast-qual warnings (2014-05-22 23:40:38 +0000)
----------------------------------------------------------------
Eric Wong (1):
list: fix -Wcast-qual warnings
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 <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 */
--
EW
More information about the ccan
mailing list