From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id CEFE45A0082 for ; Fri, 17 Feb 2023 01:43:38 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PHtN84nX2z4x8B; Fri, 17 Feb 2023 11:43:36 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1676594616; bh=kCcX2Zm/9x1SYEtMSyJqGe0DJORJazYt2xubMBxUBNI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZMfbEtTlFIVkPppUZEj2j2FVvSY48fDGt5XiBRSz3oZQv3z+H9nl+vOLXFFR3DOtN rc2jwL2scX02ygmg1E2uers7PdZ+7UD7KPKl7Dd2U5M6dYAPvfy43bkV0Y4X2/S8uo YU95bvA0039J2CUxynWnzMhgoGEnWQ9FCUtQMI8w= Date: Fri, 17 Feb 2023 09:53:28 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] conf, tap: Silence two false positive invalidFunctionArg from cppcheck Message-ID: References: <20230216182210.2290008-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QvDru+q6/rpMJJVo" Content-Disposition: inline In-Reply-To: <20230216182210.2290008-1-sbrivio@redhat.com> Message-ID-Hash: MBOUM3ZJAD77A2QD7SNNK55FYC6KE4QW X-Message-ID-Hash: MBOUM3ZJAD77A2QD7SNNK55FYC6KE4QW 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, Laine Stump X-Mailman-Version: 3.3.3 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: --QvDru+q6/rpMJJVo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 16, 2023 at 07:22:10PM +0100, Stefano Brivio wrote: > The newly introduced die() calls exit(), but cppcheck doesn't see it > and warns about possibly invalid arguments used after the check which > triggers die(). Add return statements to silence the warnings. >=20 > Signed-off-by: Stefano Brivio Oof, that's super ugly. Any chance that cppcheck will recognize the ((noreturn)) attribute if we added it to die()? > --- > conf.c | 3 +++ > tap.c | 6 +++++- > 2 files changed, 8 insertions(+), 1 deletion(-) >=20 > diff --git a/conf.c b/conf.c > index 675d961..5426c9b 100644 > --- a/conf.c > +++ b/conf.c > @@ -1036,6 +1036,9 @@ static void conf_ugid(char *runas, uid_t *uid, gid_= t *gid) > if ((fd =3D open("/proc/self/uid_map", O_RDONLY | O_CLOEXEC)) < 0) { > die("Can't determine if we're in init namespace: %s", > strerror(errno)); > + > + /* Silence cppcheck's invalidFunctionArg for 'fd' in read() */ > + return; > } > =20 > if (read(fd, buf, BUFSIZ) !=3D sizeof(root_uid_map) || > diff --git a/tap.c b/tap.c > index 88eed88..d6f962e 100644 > --- a/tap.c > +++ b/tap.c > @@ -1037,9 +1037,13 @@ static void tap_sock_unix_init(struct ctx *c) > snprintf(path, UNIX_PATH_MAX - 1, UNIX_SOCK_PATH, i); > =20 > ex =3D socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0); > - if (ex < 0) > + if (ex < 0) { > die("UNIX domain socket check: %s", strerror(errno)); > =20 > + /* Silence cppcheck's invalidFunctionArg for 'ex' */ > + return; > + } > + > ret =3D connect(ex, (const struct sockaddr *)&addr, sizeof(addr)); > if (!ret || (errno !=3D ENOENT && errno !=3D ECONNREFUSED && > errno !=3D EACCES)) { --=20 David Gibson | 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 --QvDru+q6/rpMJJVo Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmPus+IACgkQzQJF27ox 2GeDkQ//RApukmea0sCb2Lp4AgCCLhZ1QVF49sXqQvK0/wa4kGE94ccuTUQEQ3AM GznPzAjHtORIfXc27Gb6pjqkxjTVdnOpBqfATSF3ygRTVFL62RkJfg+6ZSHygj/Z xH9lFAEFzQMe0RxDi7IMON8nSx9lQjYb34MM+hr8Usqzf1HzRvb+wdlFZSVKZX0C ZrJ3ssMiz/QTJYrrlZbu3+NSfWqjn39UX4XM2IW0YWzSRLxFyE0AFfFAtFpAo5Xu QQzxtFip2Xw8QpLA+kaRRyDn4+xlUuf3yebsuVz5O4E/ZxL67q6cWILBfrkB1AIs 8qzXHnTy7xeOig3t4L1klUAdiKWA1IqeujXii6eAxS5o0oI/qCyD7wqNTMsSE9P7 lPi7YpxpMAFSaNcUDpTOAhQT+MQbW8dQ20KtVL503B3PdJSr3JsM9FXoAbRG7YBY UE6riiXbHh+MjIqepJ4ECJhiq/MyiZuQbLRM7kHx3ueWcIAStD5smEgJUB7v8igo gd9DbdQWPWGMZwnplBR9HQs/Ze++4vkL9nCtD08LM9HqvhYHwbfmrkYefiKA8W5L /NJKfx2aN1AJnalXFxSiy24acAXPO2ZfpsH+hJTPbo/iAxsh4PHx8xHjpJGh7hoO pwi5n6rkuj6FZSOcmV24LpkpbXnoOpotGZiKA5XkHWK0X4X/OPY= =sKUI -----END PGP SIGNATURE----- --QvDru+q6/rpMJJVo--