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 3DAB9C433F5 for ; Mon, 8 Nov 2021 21:00:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E8B26619E2 for ; Mon, 8 Nov 2021 21:00:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E8B26619E2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CumnMiN37uV1oTtwzZgnZnY6l5CxJCpOsXcxu1M/hX8=; b=W0rF9LjGl2wDvT CPiV/Qf9Zjl9AkaEQnwS/Ytr4e/S0wxckXnOgQUOiK4K2p5GGoHnmieofrkustCrO3jw4K8mQSwv4 ZkaFL5JZjP9QItIEoIL6VHjZSThqW8OdPlYv8TUoLung98QATAhiPqidM8sQ684aekg6ZxJLTFARm K0OTx50c7GZFPOwpPg+EJgrb7sXLPHAvrOagRxLF/DZYQSiVw+51xblCOZ14dbD4O0BYqzjwEBLdr dKatk/V59ip1zFyv43HZwjTsz9nb2xXsrExpdBuYm27EILwr/vXy8JAbOfESqjsCDVw4p+4qhGAUG 9kXWx2aLN2eGAMYIu/UQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkBjo-00HR6h-8x; Mon, 08 Nov 2021 20:59:32 +0000 Received: from netrider.rowland.org ([192.131.102.5]) by bombadil.infradead.org with smtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mkBjk-00HR5s-76 for linux-arm-kernel@lists.infradead.org; Mon, 08 Nov 2021 20:59:29 +0000 Received: (qmail 1679175 invoked by uid 1000); 8 Nov 2021 15:59:26 -0500 Date: Mon, 8 Nov 2021 15:59:26 -0500 From: Alan Stern To: Borislav Petkov Cc: Geert Uytterhoeven , LKML , Thomas Gleixner , Arnd Bergmann , Ayush Sawal , Greg Kroah-Hartman , Rohit Maheshwari , Steven Rostedt , Vinay Kumar Yadav , ALSA Development Mailing List , bcm-kernel-feedback-list , Intel Graphics Development , intel-gvt-dev@lists.freedesktop.org, alpha , Linux ARM , linux-clk , Linux Crypto Mailing List , linux-edac@vger.kernel.org, Linux Fbdev development list , linux-hyperv@vger.kernel.org, linux-iio@vger.kernel.org, linux-leds , "open list:BROADCOM NVRAM DRIVER" , Parisc List , Linux PM list , linuxppc-dev , "open list:REMOTE PROCESSOR \(REMOTEPROC\) SUBSYSTEM" , Linux-Renesas , linux-s390 , scsi , Linux-sh list , linux-staging@lists.linux.dev, linux-tegra , linux-um , USB list , "open list:TENSILICA XTENSA PORT \(xtensa\)" , netdev , openipmi-developer@lists.sourceforge.net, rcu@vger.kernel.org, sparclinux , the arch/x86 maintainers , xen-devel@lists.xenproject.org Subject: Re: [PATCH v0 42/42] notifier: Return an error when callback is already registered Message-ID: <20211108205926.GA1678880@rowland.harvard.edu> References: <20211108101157.15189-1-bp@alien8.de> <20211108101157.15189-43-bp@alien8.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211108_125928_426219_131743E2 X-CRM114-Status: GOOD ( 16.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel