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=cA5fA/Fr; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 77BE05A061A for ; Mon, 28 Oct 2024 03:14:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1730081660; bh=TmtfugWiiFoC16zjg/wbXQqaO/smIN60EaJ7L0dKuT4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cA5fA/Fr1NhMezRBlX5bB1Hc+TAFEOl+39ZBWFz0cz4DSjmmzTWu+bpkvPfAdhsoE xyU+JzHOGtPu8DewM41iCrn0RU15NUeREot6/79GDc3witrCLSWPyUXp/G3xrNpreH T8X5tzcJwY2G+AQR7OGlRoCw1ulpPRvvOMawicS0ZiEiv0GUW3EnWNvVu53fCJIwRE wIP5RsyVhQt+MYMx2g1znpibN508zhSDp48hXYPw2T50E5OHE4hbPyV5SCwKpueERz mvQvIAdHGfaZnpUseT8pA8qh5BnKUidKwUcx3T08nJ9gICRxfquWdbNfo5d0mV1MoY JBnKYfLnpPo/A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XcH585rzWz4w2L; Mon, 28 Oct 2024 13:14:20 +1100 (AEDT) Date: Mon, 28 Oct 2024 12:00:53 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 5/8] treewide: Suppress clang-tidy warning if we already use O_CLOEXEC or if we can't Message-ID: References: <20241025120814.3449347-1-sbrivio@redhat.com> <20241025120814.3449347-6-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oymga9C9TGqz1xK8" Content-Disposition: inline In-Reply-To: <20241025120814.3449347-6-sbrivio@redhat.com> Message-ID-Hash: GMKR6OUR52EY7QAH24LXVSDSN5SY5WZS X-Message-ID-Hash: GMKR6OUR52EY7QAH24LXVSDSN5SY5WZS 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: --oymga9C9TGqz1xK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 25, 2024 at 02:08:11PM +0200, Stefano Brivio wrote: > In pcap_init(), we open the packet capture file with O_CLOEXEC only > when possible. >=20 > In logfile_init() and pidfile_open(), the fact that we pass a third > 'mode' argument to open() seems to confuse the android-cloexec-open > checker in LLVM versions from 16 to 19 (at least). >=20 > The checker is suggesting to add O_CLOEXEC to 'mode', and not in > 'flags', where we already have it. >=20 > Signed-off-by: Stefano Brivio > --- > log.c | 4 ++++ > pcap.c | 1 + > util.c | 4 ++++ > 3 files changed, 9 insertions(+) >=20 > diff --git a/log.c b/log.c > index 6932885..154466f 100644 > --- a/log.c > +++ b/log.c > @@ -416,7 +416,11 @@ void logfile_init(const char *name, const char *path= , size_t size) > if (readlink("/proc/self/exe", exe, PATH_MAX - 1) < 0) > die_perror("Failed to read own /proc/self/exe link"); > =20 > + /* We use O_CLOEXEC here, but clang-tidy as of LLVM 16 to 19 looks for > + * it in the 'mode' argument if we have one, so... > + */ > log_file =3D open(path, O_CREAT | O_TRUNC | O_APPEND | O_RDWR | O_CLOEX= EC, > + /* NOLINTNEXTLINE(android-cloexec-open) */ > S_IRUSR | S_IWUSR); > if (log_file =3D=3D -1) > die_perror("Couldn't open log file %s", path); > diff --git a/pcap.c b/pcap.c > index 6ee6cdf..6753cfb 100644 > --- a/pcap.c > +++ b/pcap.c > @@ -167,6 +167,7 @@ void pcap_init(struct ctx *c) > return; > =20 > flags |=3D c->foreground ? O_CLOEXEC : 0; > + /* NOLINTNEXTLINE(android-cloexec-open): ...only where possible */ Hmm... why do we need the conditional on c->foreground? It's close-on-exec(), not close-on-fork() or close-on-daemonize(). > pcap_fd =3D open(c->pcap, flags, S_IRUSR | S_IWUSR); > if (pcap_fd =3D=3D -1) { > perror("open"); > diff --git a/util.c b/util.c > index 9cb705e..75aee81 100644 > --- a/util.c > +++ b/util.c > @@ -419,7 +419,11 @@ int pidfile_open(const char *path) > if (!*path) > return -1; > =20 > + /* We use O_CLOEXEC here, but clang-tidy as of LLVM 16 to 19 looks for > + * it in the 'mode' argument if we have one > + */ > if ((fd =3D open(path, O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC, > + /* NOLINTNEXTLINE(android-cloexec-open) */ > S_IRUSR | S_IWUSR)) < 0) { > perror("PID file open"); > exit(EXIT_FAILURE); --=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 --oymga9C9TGqz1xK8 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmce4kQACgkQzQJF27ox 2GclCg//d6vZmz/V4yvWcPNs73qD6Y3Yu9gTiKpZ8KGAUQUvjw11Fivj0zMVKtxR 6rF0aLstmXMPyeOtOuqZgfCqXmmvQhl7g/SaN8yWVzzDEljGotZohcqrx/IQwYV4 vTIIqwIgTCO4xxqhdZNE8CddM8aM/vVdEvCQXeMGBb6jLbN1s6vBIq3Z97uDfQrF 95KRaT7xwuMgo/33H6ZumUOyMUOSNI2UxMA0gRuQP3uRJ+QfLzQV5el/xlHWAt/i F8LM+tjHkvE13f4lMZk1WcxymjeVUbnExn5rSWAaDeTjYql+9m0ZbObBlLCIU4QW oaF2JK5nZJUsS21Mal/MKziGIYhKvV3a2Ns0yrK2SpbjU+g4TBeNJqVBYJpSMZPR 5MtOa2UG+TDghDjXK6K16+8cX3CybV/zadqHspHhF/uEajdKqQKjB2wYEe1iJYZY /R2aoW1YZLWXr6jNbopvEPUfoQRP3ohcALN4l4HJpz07u+5SjQ401FPgOOG6FRiO YjT46n2/RARczlBnIrhxNMZIvOuDjZK1exz2NRi2GkF2ykVBz3h/DdIyudhXkVY7 sI5buFVWCA0qI/XRZ2vjThNLZXQjqySqSNy9VAS1tP2n2tiWF20lwz7shf+EmiWj Gj5nTHSSnI1ro5rhXakhSAaqgXborG98Bpoai0rXLU/1F1gH/vI= =AQOH -----END PGP SIGNATURE----- --oymga9C9TGqz1xK8--