From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BA14C433EF for ; Mon, 8 Nov 2021 14:07:48 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 852AD610F8 for ; Mon, 8 Nov 2021 14:07:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 852AD610F8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HntH5728Cz2ynx for ; Tue, 9 Nov 2021 01:07:45 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.222.52; helo=mail-ua1-f52.google.com; envelope-from=geert.uytterhoeven@gmail.com; receiver=) Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HntGb4LSTz2ybD for ; Tue, 9 Nov 2021 01:07:19 +1100 (AEDT) Received: by mail-ua1-f52.google.com with SMTP id ay21so31622366uab.12 for ; Mon, 08 Nov 2021 06:07:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=srssYsTsVb5ivMDmTAt6Y7lXgP/lHHGiJX97jzZpFII=; b=Ts6f/MlOnmmjyptE/fTxBdmb8sqCwXwwu/vctDrKGYM1/SzhXV/V/bOZ+WHRg/WopK T2Crb122bBytfc4TG2dz7aJylGGL0OpeWdGtuMHu4XRLiPw9UUdkXkOM0H3Vsn+EyyQJ 7mNtm4soAL5ka9Ty+idpXejOSSYFwmQxDqxGZVT1X3huxg/CJRQqB3GFkMKVVbQJdmIt MVYLrlTQw+5JgxLPx8RUnQDkLJ9eUZwWQQVPTDIcy185AEuwAIvb4VgzVGBOtAtlF6DU X0pv3nXPRB75Wo/StSBVEUhatOY41wjqaTt+FYm0ErxGAxGqTYvPe3/1Lmj4Y2dAEgBY fvwg== X-Gm-Message-State: AOAM531npOqNVf7cU42FikFNG3smo+B5CUAMe9fRFWL00dVCDbXIh0uG S3eBIZbVOQhFbClpu3uZ3Cd4tQOVrgo86W8M X-Google-Smtp-Source: ABdhPJzBUGNByefDM7t3UBaEFltui041vmJuuxs4gifD4yJKDe2qqlJm9QxsPkLrr1O9GlAQbmoNCQ== X-Received: by 2002:ab0:6883:: with SMTP id t3mr201818uar.66.1636380436000; Mon, 08 Nov 2021 06:07:16 -0800 (PST) Received: from mail-vk1-f180.google.com (mail-vk1-f180.google.com. [209.85.221.180]) by smtp.gmail.com with ESMTPSA id bk3sm443137vkb.33.2021.11.08.06.07.14 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 06:07:15 -0800 (PST) Received: by mail-vk1-f180.google.com with SMTP id p22so6555533vke.7 for ; Mon, 08 Nov 2021 06:07:14 -0800 (PST) X-Received: by 2002:a05:6122:1350:: with SMTP id f16mr21288847vkp.26.1636380434409; Mon, 08 Nov 2021 06:07:14 -0800 (PST) MIME-Version: 1.0 References: <20211108101157.15189-1-bp@alien8.de> <20211108101157.15189-43-bp@alien8.de> In-Reply-To: <20211108101157.15189-43-bp@alien8.de> From: Geert Uytterhoeven Date: Mon, 8 Nov 2021 15:07:03 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered To: Borislav Petkov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: ALSA Development Mailing List , the arch/x86 maintainers , Linux-sh list , linux-iio@vger.kernel.org, "open list:REMOTE PROCESSOR \(REMOTEPROC\) SUBSYSTEM" , linux-hyperv@vger.kernel.org, "open list:BROADCOM NVRAM DRIVER" , netdev , Ayush Sawal , sparclinux , linux-clk , linux-leds , linux-s390 , scsi , Rohit Maheshwari , linux-staging@lists.linux.dev, bcm-kernel-feedback-list , openipmi-developer@lists.sourceforge.net, xen-devel@lists.xenproject.org, "open list:TENSILICA XTENSA PORT \(xtensa\)" , Arnd Bergmann , Linux PM list , Intel Graphics Development , Vinay Kumar Yadav , linux-um , Steven Rostedt , rcu@vger.kernel.org, Linux Fbdev development list , linux-tegra , Thomas Gleixner , intel-gvt-dev@lists.freedesktop.org, Linux ARM , linux-edac@vger.kernel.org, Parisc List , Greg Kroah-Hartman , USB list , LKML , Linux-Renesas , Linux Crypto Mailing List , alpha , linuxppc-dev Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Hi Borislav, On Mon, Nov 8, 2021 at 11:13 AM Borislav Petkov wrote: > From: Borislav Petkov > > The notifier registration routine doesn't return a proper error value > when a callback has already been registered, leading people to track > whether that registration has happened at the call site: > > https://lore.kernel.org/amd-gfx/20210512013058.6827-1-mukul.joshi@amd.c= om/ > > Which is unnecessary. > > Return -EEXIST to signal that case so that callers can act accordingly. > Enforce callers to check the return value, leading to loud screaming > during build: > > arch/x86/kernel/cpu/mce/core.c: In function =E2=80=98mce_register_decod= e_chain=E2=80=99: > arch/x86/kernel/cpu/mce/core.c:167:2: error: ignoring return value of \ > =E2=80=98blocking_notifier_chain_register=E2=80=99, declared with attr= ibute warn_unused_result [-Werror=3Dunused-result] > blocking_notifier_chain_register(&x86_mce_decoder_chain, nb); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Drop the WARN too, while at it. > > Suggested-by: Thomas Gleixner > Signed-off-by: Borislav Petkov Thanks for your patch! > --- a/include/linux/notifier.h > +++ b/include/linux/notifier.h > @@ -141,13 +141,13 @@ extern void srcu_init_notifier_head(struct srcu_not= ifier_head *nh); > > #ifdef __KERNEL__ > > -extern int atomic_notifier_chain_register(struct atomic_notifier_head *n= h, > +extern int __must_check atomic_notifier_chain_register(struct atomic_not= ifier_head *nh, > struct notifier_block *nb); > -extern int blocking_notifier_chain_register(struct blocking_notifier_hea= d *nh, > +extern int __must_check blocking_notifier_chain_register(struct blocking= _notifier_head *nh, > struct notifier_block *nb); > -extern int raw_notifier_chain_register(struct raw_notifier_head *nh, > +extern int __must_check raw_notifier_chain_register(struct raw_notifier_= head *nh, > struct notifier_block *nb); > -extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh, > +extern int __must_check srcu_notifier_chain_register(struct srcu_notifie= r_head *nh, > struct notifier_block *nb); I think the addition of __must_check is overkill, leading to the addition of useless error checks and message printing. 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. 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. Bu= t when I'm talking to journalists I just say "programmer" or something like t= hat. -- Linus Torvalds