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 2D755C4167D for ; Mon, 8 Nov 2021 16:12:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 03E366134F for ; Mon, 8 Nov 2021 16:12:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237274AbhKHQPR (ORCPT ); Mon, 8 Nov 2021 11:15:17 -0500 Received: from mail-ua1-f42.google.com ([209.85.222.42]:36511 "EHLO mail-ua1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbhKHQPP (ORCPT ); Mon, 8 Nov 2021 11:15:15 -0500 Received: by mail-ua1-f42.google.com with SMTP id e10so32564015uab.3; Mon, 08 Nov 2021 08:12:29 -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=hEQQmRj7LTpJogPgt2xRVOX7N+txus6iMmGepIZghfU=; b=6Syoq3UJc9F69Br0sBFpk6RXHRMeuYXTvKjf4/mPkGe4FYwxl6tGFzpgg5Ffeef7QH jXnjEmKBI2Gr5+Xow1AQTwKFMBiHN52GceJ07J01c2xOO96O7RaMIpW2fPxqhM4ltjX0 ADkJrllkqdxhszF3ASqri5CNVzXw3FMsIq+DaP0Vh8dtlWwMIslFznFFE5up3PlEAbQz M0ROOfLDGYH+D8tEQSi7tUMGNbEGm8eYCUR+bDFaEc8LuiEdgQf2F+iDlQvXjNcEVaGL THVDJhBiJ59Om9S9/FXuY0GNsdQGvF35U3YlJvq+qkSuRahZ+Wvx2/50KDXS2Ieqpxco Qzfg== X-Gm-Message-State: AOAM530E2jUS0t/A6z8puiwBo7zU97dFnqpAITI+Qi9jpLPxnz9GACEv EyrNPGOZNcZS4LazJnF/jQXArVVGU+Kix41X X-Google-Smtp-Source: ABdhPJxb7f8vOf1U8hfBptjO9dfxwRBRUSwReN0xMc/29Wjx93em3eNYCiggGS5kLSVRuKyq/aAMqQ== X-Received: by 2002:a05:6102:3ed4:: with SMTP id n20mr114208vsv.57.1636387948517; Mon, 08 Nov 2021 08:12:28 -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 t76sm2751741vkt.0.2021.11.08.08.12.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 08 Nov 2021 08:12:27 -0800 (PST) Received: by mail-vk1-f180.google.com with SMTP id t127so8459709vke.13; Mon, 08 Nov 2021 08:12:27 -0800 (PST) X-Received: by 2002:a1f:f24f:: with SMTP id q76mr347755vkh.11.1636387947335; Mon, 08 Nov 2021 08:12:27 -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 17:12:16 +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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Borislav, On Mon, Nov 8, 2021 at 4:59 PM Borislav Petkov wrote: > On Mon, Nov 08, 2021 at 04:25:47PM +0100, Geert Uytterhoeven wrote: > > 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. > > If you're against checking things at the callers, then the registration > function should be void. IOW, those APIs are not optimally designed atm. 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. 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