This commit makes macro function "ASSIGN_CONTAINER()" evaluates to "(void)0". This is to avoid the 'clang' warning: "expression result unused", since most of time, the final evaluated value is not used.
Signed-off-by: Alex Wang <al...@nicira.com> --- lib/classifier.h | 2 +- lib/hindex.h | 2 +- lib/hmap.h | 2 +- lib/list.h | 10 +++++----- lib/util.h | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/classifier.h b/lib/classifier.h index 09b3a13..a14a24d 100644 --- a/lib/classifier.h +++ b/lib/classifier.h @@ -132,7 +132,7 @@ struct cls_rule *cls_cursor_next(struct cls_cursor *, struct cls_rule *); for (ASSIGN_CONTAINER(RULE, cls_cursor_first(CURSOR), MEMBER); \ (RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER) \ ? ASSIGN_CONTAINER(NEXT, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \ - MEMBER) \ + MEMBER), 1 \ : 0); \ (RULE) = (NEXT)) diff --git a/lib/hindex.h b/lib/hindex.h index ce46596..fb6b6d2 100644 --- a/lib/hindex.h +++ b/lib/hindex.h @@ -147,7 +147,7 @@ struct hindex_node *hindex_node_with_hash(const struct hindex *, size_t hash); #define HINDEX_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HINDEX) \ for (ASSIGN_CONTAINER(NODE, hindex_first(HINDEX), MEMBER); \ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER) \ - ? ASSIGN_CONTAINER(NEXT, hindex_next(HINDEX, &(NODE)->MEMBER), MEMBER) \ + ? ASSIGN_CONTAINER(NEXT, hindex_next(HINDEX, &(NODE)->MEMBER), MEMBER), 1 \ : 0); \ (NODE) = (NEXT)) diff --git a/lib/hmap.h b/lib/hmap.h index c7df62a..ab7d3ae 100644 --- a/lib/hmap.h +++ b/lib/hmap.h @@ -146,7 +146,7 @@ bool hmap_contains(const struct hmap *, const struct hmap_node *); #define HMAP_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HMAP) \ for (ASSIGN_CONTAINER(NODE, hmap_first(HMAP), MEMBER); \ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER) \ - ? ASSIGN_CONTAINER(NEXT, hmap_next(HMAP, &(NODE)->MEMBER), MEMBER) \ + ? ASSIGN_CONTAINER(NEXT, hmap_next(HMAP, &(NODE)->MEMBER), MEMBER), 1 \ : 0); \ (NODE) = (NEXT)) diff --git a/lib/list.h b/lib/list.h index 55e0d0a..786b176 100644 --- a/lib/list.h +++ b/lib/list.h @@ -72,11 +72,11 @@ bool list_is_short(const struct list *); for (ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.prev, MEMBER); \ &(ITER)->MEMBER != (LIST); \ ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.prev, MEMBER)) -#define LIST_FOR_EACH_SAFE(ITER, NEXT, MEMBER, LIST) \ - for (ASSIGN_CONTAINER(ITER, (LIST)->next, MEMBER); \ - (&(ITER)->MEMBER != (LIST) \ - ? ASSIGN_CONTAINER(NEXT, (ITER)->MEMBER.next, MEMBER) \ - : 0); \ +#define LIST_FOR_EACH_SAFE(ITER, NEXT, MEMBER, LIST) \ + for (ASSIGN_CONTAINER(ITER, (LIST)->next, MEMBER); \ + (&(ITER)->MEMBER != (LIST) \ + ? ASSIGN_CONTAINER(NEXT, (ITER)->MEMBER.next, MEMBER), 1 \ + : 0); \ (ITER) = (NEXT)) #endif /* list.h */ diff --git a/lib/util.h b/lib/util.h index 2159594..911ad32 100644 --- a/lib/util.h +++ b/lib/util.h @@ -189,9 +189,9 @@ is_pow2(uintmax_t x) * that that OBJECT points to, assigns the address of the outer object to * OBJECT, which must be an lvalue. * - * Evaluates to 1. */ + * Evaluates to (void) 0 as the result is not to be used. */ #define ASSIGN_CONTAINER(OBJECT, POINTER, MEMBER) \ - ((OBJECT) = OBJECT_CONTAINING(POINTER, OBJECT, MEMBER), 1) + ((OBJECT) = OBJECT_CONTAINING(POINTER, OBJECT, MEMBER), (void) 0) #ifdef __cplusplus extern "C" { -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev