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 51575C433EF for ; Mon, 8 Nov 2021 15:26:28 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 DDF586115A for ; Mon, 8 Nov 2021 15:26:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DDF586115A 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.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.223470.386201 (Exim 4.92) (envelope-from ) id 1mk6X5-0003Jl-UU; Mon, 08 Nov 2021 15:26:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 223470.386201; Mon, 08 Nov 2021 15:26:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mk6X5-0003Je-RX; Mon, 08 Nov 2021 15:26:03 +0000 Received: by outflank-mailman (input) for mailman id 223470; Mon, 08 Nov 2021 15:26:02 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mk6X4-0003JX-Et for xen-devel@lists.xenproject.org; Mon, 08 Nov 2021 15:26:02 +0000 Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2d8fec45-40a8-11ec-9787-a32c541c8605; Mon, 08 Nov 2021 16:26:01 +0100 (CET) Received: by mail-ua1-f47.google.com with SMTP id b17so32287436uas.0 for ; Mon, 08 Nov 2021 07:26:01 -0800 (PST) Received: from mail-ua1-f46.google.com (mail-ua1-f46.google.com. [209.85.222.46]) by smtp.gmail.com with ESMTPSA id m15sm3319602vsh.31.2021.11.08.07.25.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 07:25:58 -0800 (PST) Received: by mail-ua1-f46.google.com with SMTP id t13so16879267uad.9 for ; Mon, 08 Nov 2021 07:25:58 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2d8fec45-40a8-11ec-9787-a32c541c8605 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=Rzx/tIbEQgnzBQwALSIU2kesFkg7kQ+IL5xhCtfASF9BkPdi+pia3+tGC23ZiXXFR7 KWQbGL3dgrhhppdVJiFj/oyVPeJ/egO0SNLZJbKt40qKHyFwIeN1AmCuqzumD3zZfMiE QubbRWP3IhCZxHkRBbmW10QXp42JZiSFd2nVB+QePAQxmQAeB8lQRg3F3zsjyyPRZ/bq 1nH8xHaQ+8zJQRmvIuEcHX7wRqS+DP9/llocolJvFMzWDoZSWHdZigEkm1WffnonXaNr GzBYG8wpHWepqbDcGIuCzBGwk3Lzz+ngPadHHP8PUrq+6be0j3fjnwMGfIvi1qbbBlrw 6BUg== X-Gm-Message-State: AOAM532FIywGxJIY6nNH8jxZvY7hCWypoN8lz1GTnzB85F9V2ZzcVITP n07J56MemIoKBmb5on+5/cOrD6GzKzyBigIs X-Google-Smtp-Source: ABdhPJzBfNOhg1XRUgrbXV4zFvq4trx2chAUm3QImI6cQa9l9gT3lcfRU4qaNWdjZy//tNutH44SlA== X-Received: by 2002:a67:fb05:: with SMTP id d5mr30403767vsr.41.1636385159930; Mon, 08 Nov 2021 07:25:59 -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 Cc: 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 Content-Type: text/plain; charset="UTF-8" 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