2
0
mirror of https://github.com/openvswitch/ovs synced 2025-09-03 15:55:19 +00:00

clang: Fix the "expression result unused" warning.

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 <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Alex Wang
2013-07-22 09:19:57 -07:00
committed by Ben Pfaff
parent 55d2690646
commit 33e191a01b
6 changed files with 13 additions and 13 deletions

View File

@@ -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); \ for (ASSIGN_CONTAINER(RULE, cls_cursor_first(CURSOR), MEMBER); \
(RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER) \ (RULE != OBJECT_CONTAINING(NULL, RULE, MEMBER) \
? ASSIGN_CONTAINER(NEXT, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \ ? ASSIGN_CONTAINER(NEXT, cls_cursor_next(CURSOR, &(RULE)->MEMBER), \
MEMBER) \ MEMBER), 1 \
: 0); \ : 0); \
(RULE) = (NEXT)) (RULE) = (NEXT))

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012 Nicira, Inc. * Copyright (c) 2012, 2013 Nicira, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -69,13 +69,13 @@ void heap_rebuild(struct heap *);
#define HEAP_FOR_EACH(NODE, MEMBER, HEAP) \ #define HEAP_FOR_EACH(NODE, MEMBER, HEAP) \
for (((HEAP)->n > 0 \ for (((HEAP)->n > 0 \
? ASSIGN_CONTAINER(NODE, (HEAP)->array[1], MEMBER) \ ? ASSIGN_CONTAINER(NODE, (HEAP)->array[1], MEMBER) \
: ((NODE) = NULL, 1)); \ : ((NODE) = NULL, (void) 0)); \
(NODE) != NULL; \ (NODE) != NULL; \
((NODE)->MEMBER.idx < (HEAP)->n \ ((NODE)->MEMBER.idx < (HEAP)->n \
? ASSIGN_CONTAINER(NODE, \ ? ASSIGN_CONTAINER(NODE, \
(HEAP)->array[(NODE)->MEMBER.idx + 1], \ (HEAP)->array[(NODE)->MEMBER.idx + 1], \
MEMBER) \ MEMBER) \
: ((NODE) = NULL, 1))) : ((NODE) = NULL, (void) 0)))
/* Returns the index of the node that is the parent of the node with the given /* Returns the index of the node that is the parent of the node with the given
* 'idx' within a heap. */ * 'idx' within a heap. */

View File

@@ -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) \ #define HINDEX_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HINDEX) \
for (ASSIGN_CONTAINER(NODE, hindex_first(HINDEX), MEMBER); \ for (ASSIGN_CONTAINER(NODE, hindex_first(HINDEX), MEMBER); \
(NODE != OBJECT_CONTAINING(NULL, NODE, 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); \ : 0); \
(NODE) = (NEXT)) (NODE) = (NEXT))

View File

@@ -146,7 +146,7 @@ bool hmap_contains(const struct hmap *, const struct hmap_node *);
#define HMAP_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HMAP) \ #define HMAP_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HMAP) \
for (ASSIGN_CONTAINER(NODE, hmap_first(HMAP), MEMBER); \ for (ASSIGN_CONTAINER(NODE, hmap_first(HMAP), MEMBER); \
(NODE != OBJECT_CONTAINING(NULL, NODE, 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); \ : 0); \
(NODE) = (NEXT)) (NODE) = (NEXT))

View File

@@ -72,11 +72,11 @@ bool list_is_short(const struct list *);
for (ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.prev, MEMBER); \ for (ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.prev, MEMBER); \
&(ITER)->MEMBER != (LIST); \ &(ITER)->MEMBER != (LIST); \
ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.prev, MEMBER)) ASSIGN_CONTAINER(ITER, (ITER)->MEMBER.prev, MEMBER))
#define LIST_FOR_EACH_SAFE(ITER, NEXT, MEMBER, LIST) \ #define LIST_FOR_EACH_SAFE(ITER, NEXT, MEMBER, LIST) \
for (ASSIGN_CONTAINER(ITER, (LIST)->next, MEMBER); \ for (ASSIGN_CONTAINER(ITER, (LIST)->next, MEMBER); \
(&(ITER)->MEMBER != (LIST) \ (&(ITER)->MEMBER != (LIST) \
? ASSIGN_CONTAINER(NEXT, (ITER)->MEMBER.next, MEMBER) \ ? ASSIGN_CONTAINER(NEXT, (ITER)->MEMBER.next, MEMBER), 1 \
: 0); \ : 0); \
(ITER) = (NEXT)) (ITER) = (NEXT))
#endif /* list.h */ #endif /* list.h */

View File

@@ -189,9 +189,9 @@ is_pow2(uintmax_t x)
* that that OBJECT points to, assigns the address of the outer object to * that that OBJECT points to, assigns the address of the outer object to
* OBJECT, which must be an lvalue. * 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) \ #define ASSIGN_CONTAINER(OBJECT, POINTER, MEMBER) \
((OBJECT) = OBJECT_CONTAINING(POINTER, OBJECT, MEMBER), 1) ((OBJECT) = OBJECT_CONTAINING(POINTER, OBJECT, MEMBER), (void) 0)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {