[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered
- To: Borislav Petkov <bp@xxxxxxxxx>
- From: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 8 Nov 2021 15:59:26 -0500
- Cc: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>, LKML <linux-kernel@xxxxxxxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Arnd Bergmann <arnd@xxxxxxxx>, Ayush Sawal <ayush.sawal@xxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Rohit Maheshwari <rohitm@xxxxxxxxxxx>, Steven Rostedt <rostedt@xxxxxxxxxxx>, Vinay Kumar Yadav <vinay.yadav@xxxxxxxxxxx>, ALSA Development Mailing List <alsa-devel@xxxxxxxxxxxxxxxx>, bcm-kernel-feedback-list <bcm-kernel-feedback-list@xxxxxxxxxxxx>, Intel Graphics Development <intel-gfx@xxxxxxxxxxxxxxxxxxxxx>, intel-gvt-dev@xxxxxxxxxxxxxxxxxxxxx, alpha <linux-alpha@xxxxxxxxxxxxxxx>, Linux ARM <linux-arm-kernel@xxxxxxxxxxxxxxxxxxx>, linux-clk <linux-clk@xxxxxxxxxxxxxxx>, Linux Crypto Mailing List <linux-crypto@xxxxxxxxxxxxxxx>, linux-edac@xxxxxxxxxxxxxxx, Linux Fbdev development list <linux-fbdev@xxxxxxxxxxxxxxx>, linux-hyperv@xxxxxxxxxxxxxxx, linux-iio@xxxxxxxxxxxxxxx, linux-leds <linux-leds@xxxxxxxxxxxxxxx>, "open list:BROADCOM NVRAM DRIVER" <linux-mips@xxxxxxxxxxxxxxx>, Parisc List <linux-parisc@xxxxxxxxxxxxxxx>, Linux PM list <linux-pm@xxxxxxxxxxxxxxx>, linuxppc-dev <linuxppc-dev@xxxxxxxxxxxxxxxx>, "open list:REMOTE PROCESSOR \(REMOTEPROC\) SUBSYSTEM" <linux-remoteproc@xxxxxxxxxxxxxxx>, Linux-Renesas <linux-renesas-soc@xxxxxxxxxxxxxxx>, linux-s390 <linux-s390@xxxxxxxxxxxxxxx>, scsi <linux-scsi@xxxxxxxxxxxxxxx>, Linux-sh list <linux-sh@xxxxxxxxxxxxxxx>, linux-staging@xxxxxxxxxxxxxxx, linux-tegra <linux-tegra@xxxxxxxxxxxxxxx>, linux-um <linux-um@xxxxxxxxxxxxxxxxxxx>, USB list <linux-usb@xxxxxxxxxxxxxxx>, "open list:TENSILICA XTENSA PORT \(xtensa\)" <linux-xtensa@xxxxxxxxxxxxxxxx>, netdev <netdev@xxxxxxxxxxxxxxx>, openipmi-developer@xxxxxxxxxxxxxxxxxxxxx, rcu@xxxxxxxxxxxxxxx, sparclinux <sparclinux@xxxxxxxxxxxxxxx>, the arch/x86 maintainers <x86@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Mon, 08 Nov 2021 21:00:10 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Mon, Nov 08, 2021 at 05:21:45PM +0100, Borislav Petkov wrote:
> On Mon, Nov 08, 2021 at 05:12:16PM +0100, Geert Uytterhoeven wrote:
> > Returning void is the other extreme ;-)
> >
> > There are 3 levels (ignoring BUG_ON()/panic () inside the callee):
> > 1. Return void: no one can check success or failure,
> > 2. Return an error code: up to the caller to decide,
> > 3. Return a __must_check error code: every caller must check.
> >
> > I'm in favor of 2, as there are several places where it cannot fail.
>
> Makes sense to me. I'll do that in the next iteration.
Is there really any reason for returning an error code? For example, is
it anticipated that at some point in the future these registration calls
might fail?
Currently, the only reason for failing to register a notifier callback
is because the callback is already registered. In a sense this isn't
even an actual failure -- after the registration returns the callback
_will_ still be registered.
So if the call can never really fail, why bother with a return code?
Especially since the caller can't do anything with such a code value.
Given the current state of affairs, I vote in favor of 1 (plus a WARN or
something similar to generate a stack dump in the callee, since double
registration really is a bug).
Alan Stern
|