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=GwMAuoM1; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id E59885A027C for ; Sat, 17 May 2025 15:07:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202504; t=1747487225; bh=Z7rq7ZKloK1B9iP1oVf/uCxrjA/4MjFnXLDlZPgghF8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GwMAuoM18FtyT9likALXrxRtF5IxeHcEB0+CdieKaq+cvtOS+GEomu7DvtApir/HE ToR/6esemns3L0xTl4OKzZYnlxsVJXzvc02JT4gahxPOBjQ+Ul9ONOuC/RXQ4xt9ya QMvPmEbq9Lf9yDR8XiXMYM5FoE3RMAf5K/gD1NrpA1Mc/tTQOde7MPvqlj6+QnpesI bva828wl2YJBytnJdBvIZ7QkBDmZTIdW2iMyHMVNS6ajmsSG0xax/iFRQGE5qBJ3NH app9adakq39fJLKCWiSwhV17yc6ztHBcxAQcpO3yD0b+Q1E/eexGzXGac6rURgnCTe 2KkKbWSSMRNjQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4b043Y6qQSz4x0t; Sat, 17 May 2025 23:07:05 +1000 (AEST) Date: Sat, 17 May 2025 20:29:20 +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> <20250516182623.69e49c29@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xpBthRgN9+xJdGWD" Content-Disposition: inline In-Reply-To: <20250516182623.69e49c29@elisabeth> Message-ID-Hash: ZVF4RY35ZE265ZRKEF5ATK4B3BKPK6HI X-Message-ID-Hash: ZVF4RY35ZE265ZRKEF5ATK4B3BKPK6HI 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: --xpBthRgN9+xJdGWD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 16, 2025 at 06:26:23PM +0200, Stefano Brivio wrote: > On Fri, 16 May 2025 17:25:21 +1000 > David Gibson wrote: >=20 > > 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 r= eturn 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 =20 > >=20 > > 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. >=20 > So, I checked, and abort_with_msg(""); works. ASSERT() ultimately > expands to abort_with_msg(), but for some reason cppcheck together with > Clang can't "follow" that, I suppose it's something related to the > pre-processor. >=20 > But in any case, abort_with_msg("") doesn't look as descriptive and > as obviously redundant as a return statement with a comment, so I don't > quite see the benefit changing it (also considering that I need to test > other versions, which takes time). Well, kind of the whole point of abort_with_msg() is that you can give it a meaningful message, which might change the picture. It would also be trivial to write an unreachable() wrapper around that. --=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 --xpBthRgN9+xJdGWD Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmgoZQAACgkQzQJF27ox 2GfU1Q/9GZ5oIdcE1yFKJlRNhap5QZ8kgm5cF1FLvXWU/8Oyl74Bp8wC3gwkWpuE 7VxQeC7h1FkPYdGpPPP+SPZF8RL2oka3DHyyrlePPcoAi3jw1wGaceOLzLfJBDvd WBVLvJ99RR9MP6g+aDV91c/ZSdDCAMdWN+Uk90v/MTi36k8pWEh44WYtWU8nzCtb 8o0eClxhEO6Y3OdUJxD4s8S+oGCKmyiAoghaImd/nEY+Fx7cWRxMseNORsLk9Hq4 yssAr45rLobsF8hlXk+cfmxbZXHzCXAw6r9DCqEW4PbMOOI+pddcoUHWq3Oi3GjK JM26GxOsE9u5mAHKc4eM4Tc1mDihgb0TQ/K1+WDODpQB5VnQwSr5XX149AvU6HGP FkC2WRzGbSBOJdk4DyscJufAJbLKpC1WPRSbb0R3JEuJUTBfe81fh9ilC9a+0mVM xAHJHUlp9ncHFROvfJHU0LoISo8Lx01GToOkd1GGxHkD6yXK9B1D7Q2u0/jbrBsG 37i/+gZR4WCrgvHHlTIWvE7rP7VLnXG+1+dNvx8z3xouQ8byf4ZHwYyXXmyYNl1f BcaVbxjR9psKA67My5yJnq+WKOPqfomHaQ0esTLX0PAUu7A27Wx5Fd0LYf2UMmFf J/y7DBQzyhp2/w1ht6Fnjrn6aFTfh34a73285V0oNt38ZvN8w5I= =Jesz -----END PGP SIGNATURE----- --xpBthRgN9+xJdGWD--