|
|
Message-ID: <20240310193956.GU4163@brightrain.aerifal.cx>
Date: Sun, 10 Mar 2024 15:39:56 -0400
From: Rich Felker <dalias@...c.org>
To: NRK <nrk@...root.org>
Cc: Alejandro Colomar <alx@...nel.org>, Guillem Jover <guillem@...rons.org>,
libc-alpha@...rceware.org, musl@...ts.openwall.com,
libbsd@...ts.freedesktop.org, "Serge E. Hallyn" <serge@...lyn.com>,
"Skyler Ferrante (RIT Student)" <sjf5462@....edu>,
Iker Pedrosa <ipedrosa@...hat.com>,
Christian Brauner <christian@...uner.io>
Subject: Re: Re: Tweaking the program name for <err.h> functions
On Sun, Mar 10, 2024 at 02:01:18PM +0000, NRK wrote:
> > or add locks; that is:
> >
> > lock()
> > fprintf("%s: ", __progname);
> > vfprintf(...);
> > unlock();
> >
> > [...]
> >
> > locking code is error-prone, I'd say.
>
> These interfaces do not guarantee the output to be atomic. If you were
> expecting it to be atomic then that's just *another* reason to roll it
> yourself because a good ton of existing implementation doesn't lock.
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...
#define warn(f,...) fprintf(stderr, "%s: " f, __progname, __VA_ARGS__)
or similar. I really see no justifiable reason for people writing new
software to want to enhance the err.h functions rather than just
rolling a one-line macro that can be better tailored to their specific
needs.
Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.