From: Willy Tarreau <w@1wt.eu>
To: Benjamin Berg <benjamin@sipsolutions.net>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
linux-um@lists.infradead.org, linux-kselftest@vger.kernel.org,
"Arnaldo Carvalho de Melo" <acme@redhat.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 03/11] tools/nolibc/stdio: remove perror if NOLIBC_IGNORE_ERRNO is set
Date: Sun, 21 Sep 2025 19:23:41 +0200 [thread overview]
Message-ID: <20250921172341.GA28493@1wt.eu> (raw)
In-Reply-To: <25a968dab7cc7e473ff85400a3a824b272121c79.camel@sipsolutions.net>
On Sun, Sep 21, 2025 at 07:16:50PM +0200, Benjamin Berg wrote:
> Hi,
>
> On Sun, 2025-09-21 at 19:13 +0200, Willy Tarreau wrote:
> > On Sun, Sep 21, 2025 at 07:05:24PM +0200, Benjamin Berg wrote:
> > > This also ties to the question of the other mail. I prefer "errno" not
> > > to be available if it is not actually safe to use. UML does use threads
> > > in some places (and may use it extensively in the future). The current
> > > "errno" implementation is not threadsafe and I see neither an obvious
> > > way nor a need to change that. By setting NOLIBC_IGNORE_ERRNO any
> > > unsafe code will not compile and can be changed to use the sys_*
> > > functions to avoid errno.
> >
> > That's the point I disagree with because here we're not using errno
> > more than printf() or dirent(). Why fix dirent() to build without errno
> > and break perror() ? Why not also break printf() then ? All of this must
> > be consistent. We're unbreaking some arbitrary functions and breaking
> > other arbitrary ones, that's not logical.
> >
> > I'm totally fine with saying that errno shouldn't be defined when building
> > without errno, but all functions must continue to be defined. perror() is
> > used to print an error message, it's a valid use case just as printf() and
> > should remain.
> >
> > If we disable perror for this, then we must also disable usage of printf
> > for consistency (and I don't want this either).
>
> Right, fair enough. It is true that it does not really hurt to keep
> perror defined. I doubt there is much code out there, but I also don't
> really have a a strong argument against keeping perror. After all, it
> will "just" result in a bad error messages rather than undefined
> behaviour.
It shouldn't be a "bad" error message, just a limited one, which is the
main purpose of ignoring errno (i.e. where we're running we don't care
about error details since the user only needs to know that it failed, or
may even not know about it at all). perror *does* display the caller's
error message. I'm personally fine with seeing:
"open(): unknown error"
for:
if (open(path, O_RDONLY) < 0)
perror("open()");
when building without errno.
Willy
next prev parent reply other threads:[~2025-09-21 17:23 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 15:34 [PATCH v2 00/11] Start porting UML to nolibc Benjamin Berg
2025-09-19 15:34 ` [PATCH v2 01/11] tools compiler.h: fix __used definition Benjamin Berg
2025-09-19 15:34 ` [PATCH v2 02/11] um: use tools/include for user files Benjamin Berg
2025-09-19 15:34 ` [PATCH v2 03/11] tools/nolibc/stdio: remove perror if NOLIBC_IGNORE_ERRNO is set Benjamin Berg
2025-09-21 7:55 ` Willy Tarreau
2025-09-21 16:37 ` Thomas Weißschuh
2025-09-21 17:05 ` Benjamin Berg
2025-09-21 17:13 ` Willy Tarreau
2025-09-21 17:16 ` Benjamin Berg
2025-09-21 17:23 ` Willy Tarreau [this message]
2025-09-21 18:26 ` Thomas Weißschuh
2025-09-21 18:28 ` Willy Tarreau
2025-09-21 17:09 ` Willy Tarreau
2025-09-19 15:34 ` [PATCH v2 04/11] tools/nolibc/dirent: avoid errno in readdir_r Benjamin Berg
2025-09-19 15:34 ` [PATCH v2 05/11] tools/nolibc: use __fallthrough__ rather than fallthrough Benjamin Berg
2025-09-19 15:34 ` [PATCH v2 06/11] tools/nolibc: add option to disable runtime Benjamin Berg
2025-09-20 9:08 ` Thomas Weißschuh
2025-09-19 15:34 ` [PATCH v2 07/11] um: add infrastructure to build files using nolibc Benjamin Berg
2025-09-21 8:13 ` Willy Tarreau
2025-09-22 7:11 ` Berg, Benjamin
2025-09-19 15:34 ` [PATCH v2 08/11] um: use nolibc for the --showconfig implementation Benjamin Berg
2025-09-19 15:34 ` [PATCH v2 09/11] tools/nolibc: add uio.h with readv and writev Benjamin Berg
2025-09-20 9:11 ` Thomas Weißschuh
2025-09-19 15:34 ` [PATCH v2 10/11] tools/nolibc: add ptrace support Benjamin Berg
2025-09-20 9:27 ` Thomas Weißschuh
2025-09-21 8:19 ` Willy Tarreau
2025-09-19 15:34 ` [PATCH v2 11/11] um: switch ptrace FP register access to nolibc Benjamin Berg
2025-09-19 20:50 ` kernel test robot
2025-09-19 15:40 ` [PATCH v2 00/11] Start porting UML " Christoph Hellwig
2025-09-22 7:41 ` Johannes Berg
2025-09-23 23:58 ` Hajime Tazaki
2025-09-24 3:32 ` Willy Tarreau
2025-09-24 7:55 ` Benjamin Berg
2025-09-25 1:05 ` Hajime Tazaki
2025-09-20 9:30 ` Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250921172341.GA28493@1wt.eu \
--to=w@1wt.eu \
--cc=acme@redhat.com \
--cc=benjamin@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=linux@weissschuh.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).