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=202410 header.b=U95YKBgl; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id CD8085A004E for ; Fri, 25 Oct 2024 03:04:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1729818252; bh=VzDr4IrSdZQtFBfE++ihPUTYZSFMuqF58qJqsZwN6U8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U95YKBglCzrRsH9O4I2PAqK9ZimUR5qcFE/dFqUUPwXW0mYkKmw7qH1n9hFOjt9lt nvcw7aQJp45J/OG/VPsgjRbqetFpuwDdodrpSvczVgW9v3nd8erT3f8r2B3U18Np76 luPXw4jeukyTTKH2GB/JukV5l7DHo3GH7w9MMpVV+2rX3j8BCbG9YQ+K9yq9qq97+H xzmDO28IrVEShv2COzhbN8Q4WOOUd/NAJBInlHZruskcPh8r4UGFLruB9eagrj4Q6g OvIKA1qY+J8ovyHBtnlSHVVaGDx/X3wLMe2xBBY4BRVNEZQg+hVF6C1uMAGU2Ieght lHxw/YdLcPvdg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XZPgc0Wlfz4wyk; Fri, 25 Oct 2024 12:04:12 +1100 (AEDT) Date: Fri, 25 Oct 2024 11:53:41 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 4/8] Makefile: Disable readability-math-missing-parentheses clang-tidy check Message-ID: References: <20241024230438.3192725-1-sbrivio@redhat.com> <20241024230438.3192725-5-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UG6Mm+1hKIXKpbTJ" Content-Disposition: inline In-Reply-To: <20241024230438.3192725-5-sbrivio@redhat.com> Message-ID-Hash: LY7RW5PGTKVSJ46USVNGUDTDCK5TP2HE X-Message-ID-Hash: LY7RW5PGTKVSJ46USVNGUDTDCK5TP2HE 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: passt-dev@passt.top 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: --UG6Mm+1hKIXKpbTJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 25, 2024 at 01:04:34AM +0200, Stefano Brivio wrote: > With clang-tidy and LLVM 19: Oh.. LLVM *19*, not *16*. That would explain why I'm not seeing the errors. >=20 > /home/sbrivio/passt/conf.c:1218:29: error: '*' has higher precedence than= '+'; add parentheses to explicitly specify the order of operations [readab= ility-math-missing-parentheses,-warnings-as-errors] > 1218 | const char *octet =3D str + 3 * i; > | ^~~~~~ > | ( ) > /home/sbrivio/passt/ndp.c:285:18: error: '*' has higher precedence than '= +'; add parentheses to explicitly specify the order of operations [readabil= ity-math-missing-parentheses,-warnings-as-errors] > 285 | .len =3D 1 + 2= * n, > | ^~~= ~~~ > | ( = ) > /home/sbrivio/passt/ndp.c:329:23: error: '%' has higher precedence than '= -'; add parentheses to explicitly specify the order of operations [readabil= ity-math-missing-parentheses,-warnings-as-errors] > 329 | memset(ptr, 0, 8 - dns_s_len % 8); /= * padding */ > | ^~~~~~~~~~~~~~ > | ( ) > /home/sbrivio/passt/pcap.c:131:20: error: '*' has higher precedence than = '+'; add parentheses to explicitly specify the order of operations [readabi= lity-math-missing-parentheses,-warnings-as-errors] > 131 | pcap_frame(iov + i * frame_parts, frame_parts, of= fset, &now); > | ^~~~~~~~~~~~~~~~ > | ( ) > /home/sbrivio/passt/util.c:216:10: error: '/' has higher precedence than = '+'; add parentheses to explicitly specify the order of operations [readabi= lity-math-missing-parentheses,-warnings-as-errors] > 216 | return (a->tv_nsec + 1000000000 - b->tv_nsec) / 1= 000 + > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ > | ( = ) > /home/sbrivio/passt/util.c:217:10: error: '*' has higher precedence than = '+'; add parentheses to explicitly specify the order of operations [readabi= lity-math-missing-parentheses,-warnings-as-errors] > 217 | (a->tv_sec - b->tv_sec - 1) * 1000000; > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | ( ) > /home/sbrivio/passt/util.c:220:9: error: '/' has higher precedence than '= +'; add parentheses to explicitly specify the order of operations [readabil= ity-math-missing-parentheses,-warnings-as-errors] > 220 | return (a->tv_nsec - b->tv_nsec) / 1000 + > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | ( ) > /home/sbrivio/passt/util.c:221:9: error: '*' has higher precedence than '= +'; add parentheses to explicitly specify the order of operations [readabil= ity-math-missing-parentheses,-warnings-as-errors] > 221 | (a->tv_sec - b->tv_sec) * 1000000; > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > | ( ) > /home/sbrivio/passt/util.c:545:32: error: '/' has higher precedence than = '+'; add parentheses to explicitly specify the order of operations [readabi= lity-math-missing-parentheses,-warnings-as-errors] > 545 | return clone(fn, stack_area + stack_size / 2, flags, arg); > | ^~~~~~~~~~~~~~~ > | ( ) >=20 > Just... no. I quite agree. Signed-off-by: David Gibson >=20 > Signed-off-by: Stefano Brivio > --- > Makefile | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/Makefile b/Makefile > index 2ebc81e..9afbb74 100644 > --- a/Makefile > +++ b/Makefile > @@ -270,6 +270,12 @@ docs: README.md > # makes sense when those defines form an enum-like set, but > # weird for cases like standalone constants, and causes other > # awkwardness for a bunch of cases we use > +# > +# - readability-math-missing-parentheses > +# It's been a couple of centuries since multiplication has been granted > +# precedence over addition in modern mathematical notation. Adding > +# parentheses to reinforce that certainly won't improve readability. > + > =20 > clang-tidy: $(filter-out qrap.c,$(SRCS)) $(HEADERS) > clang-tidy -checks=3D*,-modernize-*,\ > @@ -296,7 +302,8 @@ clang-tidy: $(filter-out qrap.c,$(SRCS)) $(HEADERS) > -concurrency-mt-unsafe,\ > -readability-identifier-length,\ > -misc-include-cleaner,\ > - -cppcoreguidelines-macro-to-enum \ > + -cppcoreguidelines-macro-to-enum,\ > + -readability-math-missing-parentheses \ > -config=3D'{CheckOptions: [{key: bugprone-suspicious-string-compare.War= nOnImplicitComparison, value: "false"}]}' \ > --warnings-as-errors=3D* $(filter-out qrap.c,$(SRCS)) -- $(filter-out -= pie,$(FLAGS) $(CFLAGS) $(CPPFLAGS)) -DCLANG_TIDY_58992 > =20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --UG6Mm+1hKIXKpbTJ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmca7BQACgkQzQJF27ox 2GcC6xAAjT8cF72dtDI0yyKvmMwKnsc4SZlBs9nQNyuP4XxULsP3pVbqa2rqb4mT nIhwuqlp4h9ABR3o661zXnZC5/Wknqp3eVR9B8jOpdzej+Po3qHFXIWb/04EGZSn E10AmQGd5FacwFocFva1CKITsrixTp9UCm2sbddfcuFhEzzNxzM3paZJfohuX0n3 QgN8IcphUYUNBVCiSdAduBWyjeeF/iH03sdN2sgZgzD2Kmskfj+IZYcjOOavKlPl MFoP2ZjVASiC5obSzMx+gmnkgFbiFtT1VIQqIM5MxFsI3032Pylqlm0ALtSUmbxb ujGv9lF8IplFHUg+29abLuJ2U9zqcT4T9ay0TU5tri6qcQDc41QXNWaZwjB/gvSr Jv+LypzS9n2whiF42a1lFiHFa+c/pJ4kMFbwPBFmIdH5bu0J3vVeR1mE0VuRjAJu yrefiqAruoEjn7J0j5ZsA2CdxoE9metGdghuXT+EC3Bz63ZxBB4EdZygIseuEFQV rrSK+YkTKwUxRwDJKwOLCuKNxQkHuUgdOLAhlbhZ3NPG63bwdYct4NS8B1Xde1XV PvEcxWArMFcTQtWBDFRHnfBdKunlQ5DaiOHojgIkvU8UkIRjrgAa7j3rx2CsGlqt hk6iVm81S//TcPD2pBwIDLzDqqxRgpnOrpuUh4ouQq5ApnI2a/c= =datT -----END PGP SIGNATURE----- --UG6Mm+1hKIXKpbTJ--