From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id A61D626875 for ; Sun, 10 Mar 2024 23:26:08 +0100 (CET) Received: (qmail 19851 invoked by uid 550); 10 Mar 2024 22:22:00 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 19822 invoked from network); 10 Mar 2024 22:21:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710109550; bh=9/N019X1vLSVhFirijtXM3SxZHEuXJ/0gYY2cUZYedg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UqbGv08sXKXr41gOORU3SfP8bP0EE7PtFrubPrted8yEus1Qp0abXxxCBLd2bveIp ToOjwDeaEDuMLdzCCVUsJSVjtMeq8NpPmomsDOqvnUhqLfQlKVroxW4MhKjKFtAsQc bS+sNszjKze4g4z1rg+9zHKaVNrU5/upqUsFd6/USjoyylZTgPl9O0OH3Q4aGLGMBW +8zlE3+Cav4bX2OpZO1laqp4F5X74n2VMn2wgH+maHo6NfYG4tW5BLIzWAaeHsbvO5 6DAJpYYbnZSfwVIazNI/U2RILHr5kAAeOje4Fw9dtjJpLIkgaURgoFhh+ylOML7+Oa xtEua9uWciy2g== Date: Sun, 10 Mar 2024 23:25:40 +0100 From: Alejandro Colomar To: Rich Felker Cc: NRK , Guillem Jover , libc-alpha@sourceware.org, musl@lists.openwall.com, libbsd@lists.freedesktop.org, "Serge E. Hallyn" , "Skyler Ferrante (RIT Student)" , Iker Pedrosa , Christian Brauner Message-ID: References: <20240309150258.GS4163@brightrain.aerifal.cx> <20240310193956.GU4163@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="2LLuXN9gXCOZ/QM1" Content-Disposition: inline In-Reply-To: <20240310193956.GU4163@brightrain.aerifal.cx> Subject: Re: [musl] Re: Tweaking the program name for functions --2LLuXN9gXCOZ/QM1 Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Sun, 10 Mar 2024 23:25:40 +0100 From: Alejandro Colomar To: Rich Felker Cc: NRK , Guillem Jover , libc-alpha@sourceware.org, musl@lists.openwall.com, libbsd@lists.freedesktop.org, "Serge E. Hallyn" , "Skyler Ferrante (RIT Student)" , Iker Pedrosa , Christian Brauner Subject: Re: [musl] Re: Tweaking the program name for functions Hi Rich, On Sun, Mar 10, 2024 at 03:39:56PM -0400, Rich Felker wrote: > Also, the whole reason this comes up is gratuitous impedance mismatch > bringing in the need for a separate fprintf call to do the prefix (and > possibly newline suffix, if you want that). They could have been > designed to be one-line macros, ala... >=20 > #define warn(f,...) fprintf(stderr, "%s: " f, __progname, __VA_ARGS__) >=20 > or similar. Hmmm, it's an interesting definition. That's actually warnx(3), but you can write the others in terms of that: #define setprogname(n) do { program_invocation_short_name =3D n; } while= (0) #define getprogname() (program_invocation_short_name) #define warnx(f, ...) fprintf(stderr, "%s: " f "\n", getprogname(), ##_= _VA_ARGS__) #define warnc(c, f, ...) warnx(f ": %s", ##__VA_ARGS__, strerror(c)) #define warn(f, ...) warnc(errno, f, ##__VA_ARGS__) #define errx(x, ...) do { warnx(__VA_ARGS__); exit(x); } while (0) #define errc(x, ...) do { warnc(__VA_ARGS__); exit(x); } while (0) #define err(x, ...) do { warn(__VA_ARGS__); exit(x); } while (0) The main problem is still portability. But I guess with some cpp(1) I can get it to work in the systems I care about. libc couldn't implement it this way, because complex things like "%2ms" wouldn't work. But it could be interesting in a multi-threaded program, where such complex conversion specifications don't occur. Still, that's not my case. I guess I'll do this: #if (!WITH_LIBBSD) inline void setprogname(const char *progname) { program_invocation_short_name =3D Basename(name); } inline const char * getprogname(void) { return program_invocation_short_name; } #endif > I really see no justifiable reason for people writing new > software to want to enhance the err.h functions rather than just I don't really need to enhance them. Just a statement that the current behavior will hold would be good enough. I would need to know that setting 'program_invocation_short_name' will set the prefix of these functions. That's already the current behavior, and I guess that you'll keep it, even if just for backwards compatibility; more so, considering your aversion to fix or break these APIs, or to change them at all. > rolling a one-line macro that can be better tailored to their specific > needs. >=20 > Rich Have a lovely night! Alex --=20 --2LLuXN9gXCOZ/QM1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmXuM2QACgkQnowa+77/ 2zJ2Gw/9F3LMOMpWkUD/rDNPXa5/nis/ljxP4aLvF3YdDSJudyRSx4PPsqECqMSC 3P+D1qCsw6SdvjkRbnxsX+KRmy3CKd/W7++e0wNNX92SybnIpFxSobfEME04k2Ox /GXPTg4pnMKSs/KH5c0a2w8F4qczDWJUQBXLRPfUaf85FpBmyN2Lhr3OPMMv32uN /lD6HLU4M1I9AOSI0pHd0ekJ/lbDun8lsYyr9bj69SDw1+0u7VS025lQBwwNt+J4 wQ/nvN0+9qki0CwiT7o0PPCwtpw9pg2rtoxf//MPEevCtgop6F1rcSPt3UdjoXiE on3gf0pB7H8wrTMjv6NLE7scmLmmcEQWrbQ4+NZq8JpqbV9eHu7pfE49Q9a9y/JK I0GxOwrclbLlqdIHkbrLoxPSlzalPQzDFCy9eBDN7YuGD7yuG8IGlf35nvRb6W38 q7F1Ld506mEBzAE6OPuy7Wptzz6XxOjujqpUfdsLP2/7nMWoIKwVhdUyNmULAVoP hb280+eSwdc1jW7S73uBK3ud/tPB/xoSWeMd6hH6JevSo50i9SI7+QIFHRdnd8CI GWlVkI8+hYm5MT7tkDS8XOHGhx63EtyOZ3FTF7bK3SLefqa1GHbNgB1OXBySFKXV crX+3uEk/v2fOSYpyKgUn8WChutdBsNNGCi8FCOQdcAc8mxBN5w= =5vk/ -----END PGP SIGNATURE----- --2LLuXN9gXCOZ/QM1--