[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: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
- Date: Mon, 8 Nov 2021 17:12:16 +0100
- Cc: 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 16:12:41 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Hi Borislav,
On Mon, Nov 8, 2021 at 4:59 PM Borislav Petkov <bp@xxxxxxxxx> wrote:
> On Mon, Nov 08, 2021 at 04:25:47PM +0100, Geert Uytterhoeven wrote:
> > I'm not against returning proper errors codes. I'm against forcing
> > callers to check things that cannot fail and to add individual error
> > printing to each and every caller.
>
> If you're against checking things at the callers, then the registration
> function should be void. IOW, those APIs are not optimally designed atm.
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.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
|