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=202504 header.b=kl1UCatm; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 2528F5A027E for ; Fri, 16 May 2025 11:07:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202504; t=1747386441; bh=7sDj1LcGxd/+igA5i/9+Ktmfbxv/rkGp37WwUmR+x68=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kl1UCatmqHyCqAZGISEMJlGwvgAHeLgXa1lkdyxM/QNsSELncLymVWQGeru3GzMu4 m+amEuGPQi0waMa0sMk3IINg9HMt6LqnfIiZ9+1+G9QR6cvKeSoap5agEIDb/DpFmD MSseNsiT/10bZIKHTzZjt6ONQmGw6vaivE3F7Z464xMsreyqHrc01dfUuHTiP4sIR3 J8K09M0KaSVEwHya6fVPf0+IKBX5FumCkqtwldiUT7wf8er6EePG8pCVSCBZyti4c1 EAV0GdnzmoDcZn1EFW07Lb2qqm/vCd3vtZo1p2tpueYxRElfeqO/oep3I3ZKBCX3kJ muo/FeDaoqZvQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4ZzLnP3grXz4x8Z; Fri, 16 May 2025 19:07:21 +1000 (AEST) Date: Fri, 16 May 2025 17:25:21 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] tap: Avoid bogus missingReturn cppcheck warning in tap_l2_max_len() Message-ID: References: <20250515160501.2636220-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="RcFqBhyahGco9J9i" Content-Disposition: inline In-Reply-To: <20250515160501.2636220-1-sbrivio@redhat.com> Message-ID-Hash: MWW3OFN4PQPHLK5L2RSVLX6UWJ6F2OIN X-Message-ID-Hash: MWW3OFN4PQPHLK5L2RSVLX6UWJ6F2OIN 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: --RcFqBhyahGco9J9i Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 15, 2025 at 06:05:01PM +0200, Stefano Brivio wrote: > Cppcheck 2.14.2 on Alpine Linux (musl) says that: >=20 > tap.c:111:19: error: Found an exit path from function with non-void retur= n type that has missing return statement [missingReturn] > switch (c->mode) { > ^ >=20 > This exit path is not reachable because we ASSERT(0) after the switch, > but for some reason cppcheck doesn't see this with musl headers. Hide > the warning with a redundant return statement. >=20 > Signed-off-by: Stefano Brivio Hm. Alternatively you could change this to call abort_with_msg() directly. That's marked as ((noreturn)) so with any luck cppcheck will then be able to figure out what's going on. Although, I'm slightly surprised it can't do so already: I thought I put the ((noreturn)) in there to avoid warnings exactly like this. > --- > tap.c | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/tap.c b/tap.c > index d630f6d..6db5d88 100644 > --- a/tap.c > +++ b/tap.c > @@ -118,6 +118,8 @@ unsigned long tap_l2_max_len(const struct ctx *c) > } > /* NOLINTEND(bugprone-branch-clone) */ > ASSERT(0); > + > + return 0; /* Unreachable, for cppcheck's sake */ > } > =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 --RcFqBhyahGco9J9i Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmgm6FIACgkQzQJF27ox 2Gc0fg//Yo/ksy4AG8hCj0nJauhzfd+NDuXdu0ajhv6FqklblhzjqGMquz/Em9Qq U3o+YV+6yieQaqOQggthOPfGyo1SOs4PiEERIloIqY5TSc0SULNL58G7D41lo6Et kyah5L3O2ctBt3ynC8CYsPiC2N8uyVHHiBVfw/jvTYriD/aDRvMbYDufBwwUxhbB W2E9tZ3JmGmlfJX+c/lQan7IaHg7Dx+9TeqYZXziGyIUMkicUfc3fQbRIFfFdgXz 0FMyHTNXqVCh64JEJlvMV2giteFwDn5FeOlbTvRZIvOkMHaZhyWFAZgsNY/iKb1/ dnmIv02yTfoidnCzku+WAO+wlV/z0Yx3psq7XqcmX3nIlH5Qfll2zqcv0TVNRmZ2 xaKfeEsE8VBQt6tV7nFsB28DOBzDp3+eDO8HEXTOdYkUSG+3EhaK6AqLsiIxOBat BHWxF6WH9drO+Fu0XW7FqM6AzuJB5agAj4ZEiGiFhwTf+34YXfm0racoSnld7bEe 5Bj93Lxqb9xRwB90BgPgmDl8z3JGyk4fXnTWW8WsrHcw1abpVsTl2bFsVHW3XlKc 4HdkIB9wFF7zK1VnwXhuyjsbntHZjS/xIdtKNQLFyWFrKldH1A7DnbwW9Dg7OaPE OHQ3r8+XELNnT22EerhuQhCweAUxCDJGjixXTZeCW5JFmzmTLpY= =vylR -----END PGP SIGNATURE----- --RcFqBhyahGco9J9i--