From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=DBRjxh4r; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 4AB655A0271 for ; Mon, 11 May 2026 12:03:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1778493804; bh=NNxEGLtjxbhZDy5+NMJxxzKE2Se47wjHCqb5u4XoVEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBRjxh4r1E3QZMzoIKL/ZO7/JTazgAatP7VqUBxhKqhG56foOcUzmpVR92ynRU1y1 J7rXN8MzW/vR4C593eYKYQCTItXZaNvIDVjb7DRtzvBFlv1RkL5eIO4QXzmknCp4M+ +YhtwcLvlUNJErDAh5SUvPFdC92xp6kgLMIcqPRYHaf/d7EzwH/gZVgZEmlMYvXmIJ 7RGnrq5xmGM1jO6ocHAzeTyYjwb86LPSZyd1hvn+h5FEDsZTxVgcLrfilWMYDozzjq ZDUqLyszaKX8CgW8BnKoJ4qn31TxcO/poZx7TUUpfNuqjuNI+ybNuRrSLvFmiS7iO8 Xzoyb9apzCJhA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4gDZzw1Xq2z4wJk; Mon, 11 May 2026 20:03:24 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 4/8] clang-tidy: Squash inconsistent brace warnings in foreach macros Date: Mon, 11 May 2026 20:03:18 +1000 Message-ID: <20260511100322.1016757-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260511100322.1016757-1-david@gibson.dropbear.id.au> References: <20260511100322.1016757-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: PZVVDCO7CKQNO76ICKTVVVOBCVVBHPXP X-Message-ID-Hash: PZVVDCO7CKQNO76ICKTVVVOBCVVBHPXP X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: clang-tidy, at least as of 22.1.4 complains about if/else statements with inconsistent braces. We generally do want consistend bracing per our coding style. However, some of our foreach macros generate inconsistent bracing in a way that can't really be avoided. Add suppressions to stop clang-tidy complaining about these. Signed-off-by: David Gibson --- flow.c | 2 ++ flow_table.h | 8 ++++++-- netlink.c | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/flow.c b/flow.c index 91f2b81f..565ed2b2 100644 --- a/flow.c +++ b/flow.c @@ -67,9 +67,11 @@ static_assert(ARRAY_SIZE(flow_epoll) == FLOW_NUM_TYPES, #define foreach_established_tcp_flow(flow) \ flow_foreach_of_type((flow), FLOW_TCP) \ + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ if (!tcp_flow_is_established(&(flow)->tcp)) \ /* NOLINTNEXTLINE(bugprone-branch-clone) */ \ continue; \ + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ else /* Global Flow Table */ diff --git a/flow_table.h b/flow_table.h index 7694e726..e4ff6f73 100644 --- a/flow_table.h +++ b/flow_table.h @@ -67,8 +67,10 @@ extern union flow flowtab[]; */ #define flow_foreach(flow) \ flow_foreach_slot((flow)) \ + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ if ((flow)->f.state == FLOW_STATE_FREE) \ (flow) += (flow)->free.n - 1; \ + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ else if ((flow)->f.state != FLOW_STATE_ACTIVE) { \ flow_err((flow), "Bad flow state during traversal"); \ continue; \ @@ -81,10 +83,12 @@ extern union flow flowtab[]; */ #define flow_foreach_of_type(flow, type_) \ flow_foreach((flow)) \ - if ((flow)->f.type != (type_)) \ + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ + if ((flow)->f.type != (type_)) \ /* NOLINTNEXTLINE(bugprone-branch-clone) */ \ continue; \ - else + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ + else \ /** flow_idx() - Index of flow from common structure diff --git a/netlink.c b/netlink.c index 9076462b..c3c830e1 100644 --- a/netlink.c +++ b/netlink.c @@ -224,6 +224,7 @@ static struct nlmsghdr *nl_next(int s, char *buf, struct nlmsghdr *nh, ssize_t * nl_foreach((nh), (status), (s), (buf), (seq)) \ if ((nh)->nlmsg_type != (type)) { \ warn("netlink: Unexpected message type"); \ + /* NOLINTNEXTLINE(readability-inconsistent-ifelse-braces) */\ } else /** -- 2.54.0