From patchwork Thu Mar 19 21:47:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Usman S. Ansari" X-Patchwork-Id: 1258481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=TrM9hsA2; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48k0r02XpVz9sPF for ; Fri, 20 Mar 2020 08:47:26 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 663D28651D; Thu, 19 Mar 2020 21:47:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 35-GgWw_dPxq; Thu, 19 Mar 2020 21:47:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9E4AF85E85; Thu, 19 Mar 2020 21:47:23 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9092BC18DA; Thu, 19 Mar 2020 21:47:23 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1EFBCC07FF for ; Thu, 19 Mar 2020 21:47:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 0E6F9232A7 for ; Thu, 19 Mar 2020 21:47:22 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eMNsTySw-1bw for ; Thu, 19 Mar 2020 21:47:21 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) by silver.osuosl.org (Postfix) with ESMTPS id 80B4720552 for ; Thu, 19 Mar 2020 21:47:21 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id ng8so1585297pjb.2 for ; Thu, 19 Mar 2020 14:47:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=BCLrc1sq76M7xU/rw1BhrZ6gmfd4aEGHVCEE2HiMbG4=; b=TrM9hsA2yTT1J2zonAOlDqUPGKrtdYeSdDPKBbf0mdGDwHL0P5z5S9+5q/WyrS7Lcl woZ2bNU02NXy/ejwoEcs+YNIK8n0sbVWEr+M9h4kDgbZ4d4KaNvg/tW0SUmiLYNmJYXn skDwolJi0C61eXbW1aX6kvR6uWxoweAtQWBawerMQ3bm8c3wiv2J5zbRpL8ruFYJKIPf 5GiFwJOY3KPgq4IVzdgO59pUVyJvyZgRoheX+raExJWUqQ+7j3kJ1CeX6X4MnCAf5q7O T55A2FK8HPFG2Usr+HSgmpUOWKQJZDivSvfZr4T1SDZNvY1t+SgroHAelxjgai8u47Dp Pryg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BCLrc1sq76M7xU/rw1BhrZ6gmfd4aEGHVCEE2HiMbG4=; b=RTxcs6tNOpLrMY8NKNpZojEpE0cai4uyeW5Tj14Ssgwb4+6Oxe2qaVgUKnTZWZ+9ZD HRc19X5XBt1ZDtY5Rkpjzi2COSi/sTKBUIh18i6qU595WSDUu9+zNKBo0UKWgbHGuU3D E1H3P3wACVaDm/namxSNoq8U720DLbXoM0yegjfQ3o+mC386FCuWbu+zI8h0d8GY1WLR 4hL4iRRQqlE4uh4osyUwaw0mATOsy7zQZxC8E5nTzuq5d/EWhjyOZUAPY0n1YPIEDibj 5XXUTMsNaBnM4h7yb3XJQZPSh+2hjcK7Hncf1uVZ4IvKkeZwWG2F1EgC1SH+tjyyc1ik DNtw== X-Gm-Message-State: ANhLgQ1R/TRwJXZxO5Bl+pirSdXUn4sttIohJWCXouqFkCQlB/paYvya 8zfQRLQYFiLvxgHE9BtLi+TWBezRi74= X-Google-Smtp-Source: ADFU+vva6Ps1Q9YtAWaUenxU19Ms0AbINX6GDTfHO0aClssZ+ZkDGnk5yyzkAwFJhyRQkuUHg/UFIA== X-Received: by 2002:a17:90a:7309:: with SMTP id m9mr5856369pjk.52.1584654440837; Thu, 19 Mar 2020 14:47:20 -0700 (PDT) Received: from linux.localdomain (c-67-180-127-245.hsd1.ca.comcast.net. [67.180.127.245]) by smtp.gmail.com with ESMTPSA id u3sm2884328pjv.32.2020.03.19.14.47.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Mar 2020 14:47:20 -0700 (PDT) From: ua1422@gmail.com To: dev@openvswitch.org Date: Thu, 19 Mar 2020 14:47:17 -0700 Message-Id: <1584654437-124095-1-git-send-email-ua1422@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: Usman Ansari Subject: [ovs-dev] [PATCH] hmap.h: Fix Coverity false positive X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Usman Ansari 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 Signed-off-by: Usman Ansari --- include/openvswitch/hmap.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/openvswitch/hmap.h b/include/openvswitch/hmap.h index 8aea9c2..74a0929 100644 --- a/include/openvswitch/hmap.h +++ b/include/openvswitch/hmap.h @@ -136,12 +136,12 @@ 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 +170,7 @@ 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 +179,7 @@ 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 +190,7 @@ 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 +211,7 @@ 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 *,