Thread (9 messages) 9 messages, 3 authors, 2021-11-08

Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered

From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: 2021-11-08 15:33:24
Also in: alsa-devel, intel-gfx, linux-alpha, linux-arm-kernel, linux-clk, linux-crypto, linux-edac, linux-hyperv, linux-iio, linux-leds, linux-mips, linux-pm, linux-remoteproc, linux-renesas-soc, linux-s390, linux-scsi, linux-sh, linux-staging, linux-tegra, linux-um, linux-usb, linuxppc-dev, lkml, netdev, rcu, sparclinux, xen-devel

Hi Borislav,

On Mon, Nov 8, 2021 at 3:21 PM Borislav Petkov [off-list ref] wrote:
On Mon, Nov 08, 2021 at 03:07:03PM +0100, Geert Uytterhoeven wrote:
quoted
I think the addition of __must_check is overkill, leading to the
addition of useless error checks and message printing.
See the WARN in notifier_chain_register() - it will already do "message
printing".
I mean the addition of useless error checks and message printing _to
the callers_.
quoted
Many callers call this where it cannot fail, and where nothing can
be done in the very unlikely event that the call would ever start to
fail.
This is an attempt to remove this WARN() hack in
notifier_chain_register() and have the function return a proper error
value instead of this "Currently always returns zero." which is bad
design.

Some of the registration functions around the tree check that retval and
some don't. So if "it cannot fail" those registration either should not
return a value or callers should check that return value - what we have
now doesn't make a whole lot of sense.
With __must_check callers are required to check, even if they know
it cannot fail.
Oh, and then fixing this should avoid stuff like:

+       if (notifier_registered == false) {
+               mce_register_decode_chain(&amdgpu_bad_page_nb);
+               notifier_registered = true;
+       }

from propagating in the code.
That's unrelated to the addition of __must_check.

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.

Note that in other areas, we are moving in the other
direction, to a centralized printing of error messages,
cfr. e.g. commit 7723f4c5ecdb8d83 ("driver core: platform: Add an
error message to platform_get_irq*()").

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help