Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4674184pxv; Tue, 27 Jul 2021 13:23:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz31KViMXY1zoHvlP5MA7PPQ/eOFerVhn1TjzZYsen312VKHgsKmywMcQSvNZjyBvXwehi0 X-Received: by 2002:a05:6638:148e:: with SMTP id j14mr23426591jak.136.1627417412021; Tue, 27 Jul 2021 13:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627417412; cv=none; d=google.com; s=arc-20160816; b=jFHJsm4j6Zuke7RT6yrambQTVR9APcIZB1PC+tYNO0OeGJ9hsx42q/DsRARJ/OvXCh W1zP4KmPDI/wqB50LDulKPS3+EKVCnS8HBdmqRt4JDoOK23b0XXpgqxLDfxNryqWtTjb drH3z25Hvs0EaKAdMszo2KOcthA/YIZS4TDEzeGkMgeKmcbxU6+rUEea8l3gVJr3q/zB aOx0f0/XaENy4IWHlqe1j30zXFQsf2ceFwsWVBo6LFlKxXEdwKsxYx43fTbtOuhCiOQF WqsT4VLcMm5Wkd+chktet4bITYcQ9U0PWM7ZbHxIncr4hGWCKOU34gr67PJxyjiCeMK9 JknA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=LMG+Pjc0zpd0uNpV6YIb/P6RindR203i0ZHENXhfOys=; b=sdpfwoEhtXKfdG8l2QPMGInqAy4yu2GE2zewD3y9/cibHP6aT9U6epikNBgeolALf6 I0CGp8vHNwT/b4t+JOFx3R6Z/4x5cmq1I4pN8sSLu98L74CgcWbFEw6Anok5raL+Pjwr F9b08CuPQ/sAuO2rJrf6TmcDXKBPFUScIyGC00fpFyWZ68qa/e2+6FmCX7q4P0bn9ZQ4 npX9TJp7LaIda0OAuwLUuBijT7yb4mtwXp8zmh4UWO11KFEVfmKyRifVCBjrxIF1yM/J 0XQniItszbn56dkSBHatYf4iUqs1iCmupgJ8vCg7Hjv5G/ksKb7i+vkbEKSXh3DEVDFA fqww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=psO33K89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x7si4860770ilu.63.2021.07.27.13.23.20; Tue, 27 Jul 2021 13:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=psO33K89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230425AbhG0UWg (ORCPT + 99 others); Tue, 27 Jul 2021 16:22:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbhG0UWf (ORCPT ); Tue, 27 Jul 2021 16:22:35 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB17BC061760 for ; Tue, 27 Jul 2021 13:22:34 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id gn26so792798ejc.3 for ; Tue, 27 Jul 2021 13:22:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LMG+Pjc0zpd0uNpV6YIb/P6RindR203i0ZHENXhfOys=; b=psO33K89BrKYXY3cfhB61uJ9PSC6boj7ts9dzDfwkRBsY+I+iAqJvIsTF2cEOaMZDq Yl8d0/COiae8Tn4tOjVWqkjqoprtkt6X5lgXVU3RcgUCQsSfw2tJFDxnHwdjsa2E/PJw bg7w8HqVGwHPZDxdwTW6q4iT6ekOSAMXmWbbftMAUvRlGXnUyDN3fP0qV5IiBgq0jp/3 yjqQ2LGlkBxbRdhdWKU0ykbIvpIMNIQSGSMVW5glAdYWYw89I5+bxPuXIleBUdnXCLPl f1Hwqd8BWmiRV702XVCMANy22y92QF+EXd0byD1tBFpGg/D07DuhxPR3F6Wchj2GYjVw 2u5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LMG+Pjc0zpd0uNpV6YIb/P6RindR203i0ZHENXhfOys=; b=T3bdAnslFCHOJGz80z+yjW6KLc4noofTqb+4Sni9o03uQf1Db5OQx22M6kobG6LBwv m+i+5XYWYTbVzY1VYeIgEiFT0yzLpucG76mpggh++BKLlbZauiJH+kAUMGFI7q2qI4Qq 6g+A2CO1xM4bWzUTuuaSq5qk94Ae73wE4hZ/I2dHN6LoZenKo/L7Be8M2ZK9Iw8uaBss GpXKKKl4bcL+706+MiHXt4+E9HHgZilLB67d/AaB4sZjHd/EXz2MOqJA3pX3njNCHxfR q26d+6MDcCcRFvT431SdBWC4dMJLH2LaDNrKov25S4mOIk9kgjvon7/sgcBDYM6x1TVO 8pjQ== X-Gm-Message-State: AOAM5304LkWfGmTAq6Kqg4rz9uf4BhsjYioDzz+xa5J9BCEFeerYm8l3 x0qVzAqoNNg1y0lr1Y+Pn9HKB/ItywYiLDPFIaxs X-Received: by 2002:a17:906:7951:: with SMTP id l17mr23806775ejo.529.1627417353173; Tue, 27 Jul 2021 13:22:33 -0700 (PDT) MIME-Version: 1.0 References: <20210714091747.2814370-1-morbo@google.com> <20210726201924.3202278-1-morbo@google.com> <20210726201924.3202278-2-morbo@google.com> <20210727201328.GY1583@gate.crashing.org> In-Reply-To: <20210727201328.GY1583@gate.crashing.org> From: Bill Wendling Date: Tue, 27 Jul 2021 13:22:21 -0700 Message-ID: Subject: Re: [PATCH v2 1/3] base: mark 'no_warn' as unused To: Segher Boessenkool Cc: Greg Kroah-Hartman , Nick Desaulniers , Nathan Chancellor , "Rafael J. Wysocki" , clang-built-linux , LKML , linux-toolchains@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 27, 2021 at 1:17 PM Segher Boessenkool wrote: > > On Tue, Jul 27, 2021 at 07:59:24PM +0200, Greg Kroah-Hartman wrote: > > On Tue, Jul 27, 2021 at 10:39:49AM -0700, Nick Desaulniers wrote: > > > I think warn_unused_result should only really be used for functions > > > where the return value should be used 100% of the time. > > > > I too want a shiny new pony. > > > > But here in the real world, sometimes you have functions that for 99% of > > the users, you do want them to check the return value, but when you use > > them in core code or startup code, you "know" you are safe to ignore the > > return value. > > > > That is the case here. We have other fun examples of where people have > > tried to add error handling to code that runs at boot that have actually > > introduced security errors and they justify it with "but you have to > > check error values!" > > > > > If there are > > > cases where it's ok to not check the return value, consider not using > > > warn_unused_result on function declarations. > > > > Ok, so what do you do when you have a function like this where 99.9% of > > the users need to check this? Do I really need to write a wrapper > > function just for it so that I can use it "safely" in the core code > > instead? > > > > Something like: > > > > void do_safe_thing_and_ignore_the_world(...) > > { > > __unused int error; > > > > error = do_thing(...); > > } > > > > Or something else to get the compiler to be quiet about error being set > > and never used? > > The simplest is to write > if (do_thing()) { > /* Nothing here, we can safely ignore the return value > * here, because of X and Y and I don't know, I have no > * idea actually why we can in this example. Hopefully > * in real code people do have a good reason :-) > */ > } > > which should work in *any* compiler, doesn't need any extension, is > quite elegant, and encourages documenting why we ignore the return > value here. > Or better still, use sysfs_create_link_nowarn() instead of sysfs_create_link(). We'll just have to take the "__must_check" attribute off the sysfs_create_link_nowarn() declaration. -bw