summaryrefslogtreecommitdiff
path: root/include/openvswitch
diff options
context:
space:
mode:
authorUsman Ansari <ua1422@gmail.com>2020-03-19 14:47:17 -0700
committerBen Pfaff <blp@ovn.org>2020-03-19 15:08:29 -0700
commit8c544570cb3a1e09009e2d637cbd7075afc7ed03 (patch)
tree8a707951e1c0e5ef7acef35ef9be9c4d5ad6c6c8 /include/openvswitch
parent65b84d4a32bdcb6ed8605988f4cedb58a753e184 (diff)
downloadopenvswitch-8c544570cb3a1e09009e2d637cbd7075afc7ed03.tar.gz
hmap: Fix Coverity false positive
Coverity reports a false positive below: Incorrect expression, Assign_where_compare_meant: use of "=" where "==" may have been intended. Fixed it by rewriting '(NODE = NULL)' as '((NODE = NULL), false)'. "make check" passes for this change Coverity reports over 500 errors resolved Suggested-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Usman Ansari <ua1422@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'include/openvswitch')
-rw-r--r--include/openvswitch/hmap.h18
1 files changed, 12 insertions, 6 deletions
diff --git a/include/openvswitch/hmap.h b/include/openvswitch/hmap.h
index 8aea9c22d..4e001cc69 100644
--- a/include/openvswitch/hmap.h
+++ b/include/openvswitch/hmap.h
@@ -136,12 +136,14 @@ struct hmap_node *hmap_random_node(const struct hmap *);
*/
#define HMAP_FOR_EACH_WITH_HASH(NODE, MEMBER, HASH, HMAP) \
for (INIT_CONTAINER(NODE, hmap_first_with_hash(HMAP, HASH), MEMBER); \
- (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL); \
+ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
+ || ((NODE = NULL), false); \
ASSIGN_CONTAINER(NODE, hmap_next_with_hash(&(NODE)->MEMBER), \
MEMBER))
#define HMAP_FOR_EACH_IN_BUCKET(NODE, MEMBER, HASH, HMAP) \
for (INIT_CONTAINER(NODE, hmap_first_in_bucket(HMAP, HASH), MEMBER); \
- (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL); \
+ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
+ || ((NODE = NULL), false); \
ASSIGN_CONTAINER(NODE, hmap_next_in_bucket(&(NODE)->MEMBER), MEMBER))
static inline struct hmap_node *hmap_first_with_hash(const struct hmap *,
@@ -170,7 +172,8 @@ bool hmap_contains(const struct hmap *, const struct hmap_node *);
HMAP_FOR_EACH_INIT(NODE, MEMBER, HMAP, (void) 0)
#define HMAP_FOR_EACH_INIT(NODE, MEMBER, HMAP, ...) \
for (INIT_CONTAINER(NODE, hmap_first(HMAP), MEMBER), __VA_ARGS__; \
- (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL); \
+ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
+ || ((NODE = NULL), false); \
ASSIGN_CONTAINER(NODE, hmap_next(HMAP, &(NODE)->MEMBER), MEMBER))
/* Safe when NODE may be freed (not needed when NODE may be removed from the
@@ -179,7 +182,8 @@ bool hmap_contains(const struct hmap *, const struct hmap_node *);
HMAP_FOR_EACH_SAFE_INIT(NODE, NEXT, MEMBER, HMAP, (void) 0)
#define HMAP_FOR_EACH_SAFE_INIT(NODE, NEXT, MEMBER, HMAP, ...) \
for (INIT_CONTAINER(NODE, hmap_first(HMAP), MEMBER), __VA_ARGS__; \
- ((NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL) \
+ ((NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
+ || ((NODE = NULL), false) \
? INIT_CONTAINER(NEXT, hmap_next(HMAP, &(NODE)->MEMBER), MEMBER), 1 \
: 0); \
(NODE) = (NEXT))
@@ -190,7 +194,8 @@ bool hmap_contains(const struct hmap *, const struct hmap_node *);
#define HMAP_FOR_EACH_CONTINUE_INIT(NODE, MEMBER, HMAP, ...) \
for (ASSIGN_CONTAINER(NODE, hmap_next(HMAP, &(NODE)->MEMBER), MEMBER), \
__VA_ARGS__; \
- (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL); \
+ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
+ || ((NODE = NULL), false); \
ASSIGN_CONTAINER(NODE, hmap_next(HMAP, &(NODE)->MEMBER), MEMBER))
static inline struct hmap_node *
@@ -211,7 +216,8 @@ hmap_pop_helper__(struct hmap *hmap, size_t *bucket) {
#define HMAP_FOR_EACH_POP(NODE, MEMBER, HMAP) \
for (size_t bucket__ = 0; \
INIT_CONTAINER(NODE, hmap_pop_helper__(HMAP, &bucket__), MEMBER), \
- (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) || (NODE = NULL);)
+ (NODE != OBJECT_CONTAINING(NULL, NODE, MEMBER)) \
+ || ((NODE = NULL), false);)
static inline struct hmap_node *hmap_first(const struct hmap *);
static inline struct hmap_node *hmap_next(const struct hmap *,