[ovs-dev] [PATCH] hmap.h: Fix Coverity false positive

Usman Ansari ua1422 at gmail.com
Thu Mar 19 00:32:03 UTC 2020


Suggested-by: Ben Pfaff <blp at ovn.org>

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 80 errors resolved

Signed-off-by: Usman Ansari <u1422 at gmail.com>
---
 include/openvswitch/hmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/openvswitch/hmap.h b/include/openvswitch/hmap.h
index 8aea9c2..f48359f 100644
--- a/include/openvswitch/hmap.h
+++ b/include/openvswitch/hmap.h
@@ -136,7 +136,7 @@ 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)               \
-- 
2.7.4


More information about the dev mailing list