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 31380C433EF for ; Mon, 8 Nov 2021 15:34:45 +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 992BE61359 for ; Mon, 8 Nov 2021 15:34:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 992BE61359 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 4HnwCQ733nz3cFf for ; Tue, 9 Nov 2021 02:34:42 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=209.85.167.180; helo=mail-oi1-f180.google.com; envelope-from=geert.uytterhoeven@gmail.com; receiver=) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 4HnwBs6LWvz2yHX for ; Tue, 9 Nov 2021 02:34:11 +1100 (AEDT) Received: by mail-oi1-f180.google.com with SMTP id u74so6985364oie.8 for ; Mon, 08 Nov 2021 07:34:11 -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; bh=x4ykPITI22sSh/L6reU4seHVLFfVjdO/v+W3/SN8DUg=; b=wtMBCqW9hnpYLzHMsgMHy1kNTAAU9PIkELwI5r8H88eNjU4mggC8y6/M0Y5VUeE9Nb IkPWCr1uxNuMVroc1cUe4LrtOMr0d9N+X+IVmPjnverzibyni58ZH2/kLQrt6DUa02R4 DKBl//dm3kJCpY5a4cI4xTV5DEdj+QTQjHXRADqtj4iDsZoFYkIrHIbsSHx7ZbaWWstD xsLzANOOHCp90W8VzV/I3V8KpKVx7aPW8A9kcAXSjDiVCQ5GhPsAmpbGqjtwEM2f/r6B n3adv7DmcHC6MTK6/JVFcI+ijaK6lA2JszDuMpE1hyZ37su01m4ZDfJH/KfJJ8zRBQ6T S82A== X-Gm-Message-State: AOAM533y1SIk3nU9lQxJOVHKrvexsAu8YbtvYQF/l3gM/8KJX/KTAxjI OqXsHSItsFT6TanGi9iU9D2icE2UR5dentHP X-Google-Smtp-Source: ABdhPJyfhSzYyyAUTeFb5/jiMPU9zdR6ziU48nYFpXWllODmQGjBaJHTSR4gBWdURGo+2l1M3dniug== X-Received: by 2002:aca:33c6:: with SMTP id z189mr31761781oiz.61.1636385649002; Mon, 08 Nov 2021 07:34:09 -0800 (PST) Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com. [209.85.210.43]) by smtp.gmail.com with ESMTPSA id 70sm6276768otn.74.2021.11.08.07.34.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 07:34:08 -0800 (PST) Received: by mail-ot1-f43.google.com with SMTP id v40-20020a056830092800b0055591caa9c6so26108184ott.4 for ; Mon, 08 Nov 2021 07:34:08 -0800 (PST) X-Received: by 2002:a9f:2c98:: with SMTP id w24mr725068uaj.89.1636385158322; Mon, 08 Nov 2021 07:25:58 -0800 (PST) MIME-Version: 1.0 References: <20211108101157.15189-1-bp@alien8.de> <20211108101157.15189-43-bp@alien8.de> In-Reply-To: From: Geert Uytterhoeven Date: Mon, 8 Nov 2021 16:25:47 +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" 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 3:21 PM Borislav Petkov wrote: > On Mon, Nov 08, 2021 at 03:07:03PM +0100, Geert Uytterhoeven wrote: > > 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_. > > 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