public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH 0/3] Fix 'make clang-tidy' with clang-tidy 23
@ 2026-11-20  1:32 Jon Maloy
  2026-11-20  1:32 ` [PATCH 1/3] clang-tidy: Also disable bugprone-signed-bitwise Jon Maloy
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jon Maloy @ 2026-11-20  1:32 UTC (permalink / raw)
  To: sbrivio, david, jmaloy, passt-dev

Fedora 45 ships clang-tidy 23.1.5, which breaks 'make clang-tidy' for
three reasons: clang-tidy 23 dropped the hicpp module, so our
existing exclusion for hicpp-signed-bitwise no longer applies to the
check, now called bugprone-signed-bitwise; it adds a few new checks
that don't fit our coding style; and an existing check now flags some
redundant parentheses in passt-repair.

Patches 1 and 2 adjust .clang-tidy, patch 3 fixes passt-repair.c.
With these, 'make clang-tidy' passes again for passt, passt-repair
and pesto, and nothing changes for older clang-tidy versions.

Jon Maloy (3):
  clang-tidy: Also disable bugprone-signed-bitwise
  clang-tidy: Disable checks new in clang-tidy 23
  passt-repair: Drop redundant parentheses around stat() calls

 .clang-tidy    | 18 ++++++++++++++++--
 passt-repair.c |  4 ++--
 2 files changed, 18 insertions(+), 4 deletions(-)

-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] clang-tidy: Also disable bugprone-signed-bitwise
  2026-11-20  1:32 [PATCH 0/3] Fix 'make clang-tidy' with clang-tidy 23 Jon Maloy
@ 2026-11-20  1:32 ` Jon Maloy
  2026-11-20  1:32 ` [PATCH 2/3] clang-tidy: Disable checks new in clang-tidy 23 Jon Maloy
  2026-11-20  1:32 ` [PATCH 3/3] passt-repair: Drop redundant parentheses around stat() calls Jon Maloy
  2 siblings, 0 replies; 4+ messages in thread
From: Jon Maloy @ 2026-11-20  1:32 UTC (permalink / raw)
  To: sbrivio, david, jmaloy, passt-dev

The hicpp-signed-bitwise check is disabled in .clang-tidy, as we need
bitwise operations on signed values for syscalls, epoll_wait() flags,
etc.

clang-tidy 23 removed the hicpp module, moving its checks to other
modules, and hicpp-signed-bitwise became bugprone-signed-bitwise. The
existing exclusion therefore no longer applies, and as we enable all
checks and treat warnings as errors, 'make clang-tidy' fails with
clang-tidy 23.1.5, e.g.:

  arp.c:139:37: error: use of a signed integer operand with a binary
  bitwise operator [bugprone-signed-bitwise,-warnings-as-errors]
    139 |         a = fwd_get_addr(c, AF_INET, true, CONF_ADDR_ANY);

where CONF_ADDR_ANY is built from BIT(n), that is, (1UL << (n)), and
the shift count is a signed int.

Disable the check under its new name as well, keeping the old one for
older clang-tidy versions.

Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
 .clang-tidy | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.clang-tidy b/.clang-tidy
index 9ba43bf0..ec570f2d 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -26,8 +26,10 @@ Checks:
     #	TODO: this is Linux-only for the moment, nice to fix eventually
     - "-llvmlibc-restrict-system-libc-headers"
 
-    #	Those are needed for syscalls, epoll_wait flags, etc.
+    #	Those are needed for syscalls, epoll_wait flags, etc.  Moved
+    #	from hicpp to bugprone as clang-tidy 23 dropped the hicpp module
     - "-hicpp-signed-bitwise"
+    - "-bugprone-signed-bitwise"
 
     #	Probably not doable to impement this without plain memcpy(), memset()
     - "-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling"
-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] clang-tidy: Disable checks new in clang-tidy 23
  2026-11-20  1:32 [PATCH 0/3] Fix 'make clang-tidy' with clang-tidy 23 Jon Maloy
  2026-11-20  1:32 ` [PATCH 1/3] clang-tidy: Also disable bugprone-signed-bitwise Jon Maloy
@ 2026-11-20  1:32 ` Jon Maloy
  2026-11-20  1:32 ` [PATCH 3/3] passt-repair: Drop redundant parentheses around stat() calls Jon Maloy
  2 siblings, 0 replies; 4+ messages in thread
From: Jon Maloy @ 2026-11-20  1:32 UTC (permalink / raw)
  To: sbrivio, david, jmaloy, passt-dev

clang-tidy 23 introduces three new checks, which make
'make clang-tidy' fail on code that's otherwise fine:

- readability-trailing-comma wants a trailing comma in every
  multi-line initialiser list, and none in single-line ones. That's
  not part of our coding style, and it reports about 30 sites
  (dhcpv6.c, ndp.c, netlink.c, pcap.c, tap.c, ...)

- readability-redundant-nested-if wants nested if statements merged
  into a single condition, also where the inner condition has side
  effects, as in bind() or setsockopt() calls, or a dedicated comment
  (util.c, tcp.c, ...). Merging those would hurt readability, much
  like the braces-around-statements checks we already disable

- bugprone-assignment-in-selection-statement, which cert-exp45-c is
  now an alias of, reports assignments in conditions (conf.c, flow.c,
  udp.c), like bugprone-assignment-in-if-condition, which we already
  disable for the same reasons

Disable these checks.

Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
 .clang-tidy | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/.clang-tidy b/.clang-tidy
index ec570f2d..6aceb44a 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -9,8 +9,11 @@ Checks:
     - "-cppcoreguidelines-init-variables"
 
     #	Dubious value over the compiler's built-in warning.  Would
-    #	increase verbosity.
+    #	increase verbosity.  Same for its broader variant, added in
+    #	clang-tidy 23, also known as cert-exp45-c
     - "-bugprone-assignment-in-if-condition"
+    - "-bugprone-assignment-in-selection-statement"
+    - "-cert-exp45-c"
 
     #	Debatable whether these improve readability, right now it would look
     #	like a mess
@@ -99,6 +102,15 @@ Checks:
     # be treated directly as a bool.
     - "-readability-implicit-bool-conversion"
 
+    # Wants trailing commas in multi-line initialiser lists, and none in
+    # single-line ones.  Not part of our coding style, and enforcing it
+    # would mean churn all over the place for no practical benefit.
+    - "-readability-trailing-comma"
+
+    # Merging nested if statements would often hurt readability, e.g.
+    # where the inner condition has side effects or a separate comment.
+    - "-readability-redundant-nested-if"
+
 WarningsAsErrors: "*"
 HeaderFileExtensions:
     - h
-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] passt-repair: Drop redundant parentheses around stat() calls
  2026-11-20  1:32 [PATCH 0/3] Fix 'make clang-tidy' with clang-tidy 23 Jon Maloy
  2026-11-20  1:32 ` [PATCH 1/3] clang-tidy: Also disable bugprone-signed-bitwise Jon Maloy
  2026-11-20  1:32 ` [PATCH 2/3] clang-tidy: Disable checks new in clang-tidy 23 Jon Maloy
@ 2026-11-20  1:32 ` Jon Maloy
  2 siblings, 0 replies; 4+ messages in thread
From: Jon Maloy @ 2026-11-20  1:32 UTC (permalink / raw)
  To: sbrivio, david, jmaloy, passt-dev

clang-tidy 23.1.5 reports:

  passt-repair.c:122:6: error: redundant parentheses around expression
  [readability-redundant-parentheses,-warnings-as-errors]
    122 |         if ((stat(a->sun_path, sb))) {

and the same for the stat() call in main(). There's no assignment in
those conditions, so the extra parentheses are pointless. Drop them.

Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
 passt-repair.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/passt-repair.c b/passt-repair.c
index 3958c3af..2a147432 100644
--- a/passt-repair.c
+++ b/passt-repair.c
@@ -119,7 +119,7 @@ static int wait_for_socket(struct sockaddr_un *a, const char *dir,
 	ret = snprintf(a->sun_path, sizeof(a->sun_path), "%s/%s",
 		       dir, ev->name);
 
-	if ((stat(a->sun_path, sb))) {
+	if (stat(a->sun_path, sb)) {
 		FPRINTF(stderr, "Can't stat() %s: %i\n", a->sun_path, errno);
 		_exit(1);
 	}
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
 		_exit(1);
 	}
 
-	if ((stat(argv[1], &sb))) {
+	if (stat(argv[1], &sb)) {
 		FPRINTF(stderr, "Can't stat() %s: %i\n", argv[1], errno);
 		_exit(1);
 	}
-- 
2.56.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-20  1:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20  1:32 [PATCH 0/3] Fix 'make clang-tidy' with clang-tidy 23 Jon Maloy
2026-11-20  1:32 ` [PATCH 1/3] clang-tidy: Also disable bugprone-signed-bitwise Jon Maloy
2026-11-20  1:32 ` [PATCH 2/3] clang-tidy: Disable checks new in clang-tidy 23 Jon Maloy
2026-11-20  1:32 ` [PATCH 3/3] passt-repair: Drop redundant parentheses around stat() calls Jon Maloy

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).