Linux Overlay Filesystem development
 help / color / mirror / Atom feed
From: Rasmus Villemoes <ravi@prevas.dk>
To: Amir Goldstein <amir73il@gmail.com>
Cc: David Laight <david.laight.linux@gmail.com>,
	 Miklos Szeredi <miklos@szeredi.hu>,
	 Christian Brauner <brauner@kernel.org>,  Jan Kara <jack@suse.cz>,
	 Al Viro <viro@zeniv.linux.org.uk>,
	 Linus Torvalds <torvalds@linux-foundation.org>,
	 Nirmoy Das <nirmoyd@nvidia.com>,
	linux-unionfs@vger.kernel.org,  linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] err_ptr.h: introduce ERR_PTR_SAFE()
Date: Mon, 18 May 2026 11:04:09 +0200	[thread overview]
Message-ID: <87se7pdr7a.fsf@prevas.dk> (raw)
In-Reply-To: <CAOQ4uxjX=C6WZvW1DdJ13tJj-XBWVxgE2Q9vVvHoYqiOhqW0wQ@mail.gmail.com> (Amir Goldstein's message of "Sat, 16 May 2026 13:39:11 +0200")

On Sat, May 16 2026, Amir Goldstein <amir73il@gmail.com> wrote:

> On Sat, May 16, 2026 at 10:42 AM David Laight
> <david.laight.linux@gmail.com> wrote:
>>
>> On Fri, 15 May 2026 21:26:04 +0200
>> Amir Goldstein <amir73il@gmail.com> wrote:
>>
>> > On Fri, May 15, 2026 at 8:30 PM David Laight
>> > <david.laight.linux@gmail.com> wrote:
>> > >
>> > > On Thu, 14 May 2026 22:01:29 +0200
>> > > Amir Goldstein <amir73il@gmail.com> wrote:
>> > >
>> ...
>> > >
>> > > The object code bloat would be noticeable if this were used everywhere.
>> > > But you could make it a bit simpler:
>> > >         if (__builtin_constant_p(__e))
>> > >                 BUILD_BUG_ON(__e && !IS_ERR_VALUE(__e));
>> > >         else if WARN_ON(__e && !IS_ERR_VALUE(__e))
>> > >                 __e = -MAX_ERRNO; // Or maybe -EINVAL to stop and other boundary errors
>> > >         (void *)__e;
>> >
>> > Yeh that's nicer thanks.
>>
>> Actually this might be better still (or just more succinct):
>>         void *__e = (void *)error;
>>         BUILD_BUG_ON(!statically_true(IS_ERR_OR_NULL(__e));
>
> This condition is wrong but also my compiler does not evaluate
> __builtin_constant_p(IS_ERR_OR_NULL(__e)) as true.
>
> This works
> BUILD_BUG_ON(statically_true(!IS_ERR_VALUE(__e)));
>
> I think it is enough to statically assert on ERR_PTR(EINVAL)
> and no need to bother with ERR_PTR(0)
>
>>         if (WARN_ON(!IS_ERR_OR_NULL(__e))
>>                 __e = (void *)-EINVAL;
>
> Oh, anything but EINVAL please - the most overloaded error value
> My choice of meaningful error value would be EFAULT

Could we have a dedicated "EBUG" that can be used to indicate "there's a
bug somewhere in the kernel, we can handle it somewhat gracefully here
by returning an error instead of BUG(). You can't do anything about it
but report that you got -EBUG from $this_syscall", instead of
overloading EIO, EFAULT, EINVAL or whatnot. Internally, EBUG could be a
macro that did ({ WARN_ONCE(); -__EBUG; }) or something, so there would
automatically be bread crumbs in dmesg if it is ever hit.

Userspace code could also benefit from having EBUG to indicate that some
internal inconsistency has been detected.

Rasmus

  parent reply	other threads:[~2026-05-18  9:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-14 20:01 [PATCH] err_ptr.h: introduce ERR_PTR_SAFE() Amir Goldstein
2026-05-15 12:25 ` Nirmoy Das
2026-05-15 13:15 ` Jori Koolstra
2026-05-15 18:30 ` David Laight
2026-05-15 19:26   ` Amir Goldstein
2026-05-16  8:42     ` David Laight
2026-05-16 11:39       ` Amir Goldstein
2026-05-16 12:42         ` David Laight
2026-05-16 20:39           ` Amir Goldstein
2026-05-18  9:04         ` Rasmus Villemoes [this message]
2026-05-18  9:52           ` Amir Goldstein
2026-05-18 12:48             ` David Laight
2026-05-17  9:13       ` Andreas Dilger
2026-05-17 12:40         ` David Laight
2026-05-18 12:39 ` Christian Brauner
2026-05-18 12:52   ` Amir Goldstein
2026-05-18 14:51     ` David Laight

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=87se7pdr7a.fsf@prevas.dk \
    --to=ravi@prevas.dk \
    --cc=amir73il@gmail.com \
    --cc=brauner@kernel.org \
    --cc=david.laight.linux@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=nirmoyd@nvidia.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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