From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: Re: [PATCH 20/28] cppcheck: Suppress same-value-in-ternary branches warning Date: Wed, 28 Sep 2022 22:58:06 +0200 Message-ID: <20220928225806.101066a9@elisabeth> In-Reply-To: <20220928043339.613538-21-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2416164214593218580==" --===============2416164214593218580== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Wed, 28 Sep 2022 14:33:31 +1000 David Gibson wrote: > TIMER_INTERVAL is the minimum of two separately defined intervals which > happen to have the same value at present. This results in an expression > which has the same value in both branches of a ternary operator, which > cppcheck warngs about. This is logically sound in this case, so suppress > the error (we appear to already have a similar suppression for clang-tidy). > > Also add an unmatchedSuppression suppression, since only some cppcheck > versions complain about this instance. > > Signed-off-by: David Gibson > --- > passt.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/passt.c b/passt.c > index 4796c89..2c4a986 100644 > --- a/passt.c > +++ b/passt.c > @@ -305,6 +305,7 @@ int main(int argc, char **argv) > > loop: > /* NOLINTNEXTLINE(bugprone-branch-clone): intervals can be the same */ > + /* cppcheck-suppress [duplicateValueTernary, unmatchedSuppression] */ Somewhat surprisingly to me, NOLINTNEXTLINE means "next line of code", not next line altogether -- given that this still works (I wouldn't have even tried). -- Stefano --===============2416164214593218580==--