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 X-Spam-Level: X-Spam-Status: No, score=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB713C4338F for ; Tue, 27 Jul 2021 18:31:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA2C560F9F for ; Tue, 27 Jul 2021 18:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbhG0Sbw (ORCPT ); Tue, 27 Jul 2021 14:31:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbhG0Sbv (ORCPT ); Tue, 27 Jul 2021 14:31:51 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81BAFC061757 for ; Tue, 27 Jul 2021 11:31:51 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id h11so17080945ljo.12 for ; Tue, 27 Jul 2021 11:31:51 -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=WzCeD96mdqS8ayUSQrtfxYNv5qyDkHlLyxEuT5l/fk4=; b=LzpEn20DuqJpfX0MM3CcahlLGfteKX6Zz6d6/G9/QDwM/LWXg1fL3kVu4luyf0RnDO K77CSVRHIqb1nvhebKA+k6z7K7TgGSwbrYDuYngJxkA6biKRO3i4HE5ahJ8PuoqJnJH0 p14B3GPlfvmYXALdCHCBf+7htZ5skshF3jZjWwb/5Y0V0wpJk8/jYsAP/eTSVkO1A45O qW3rnWhwfEFMWasUg7XZDrf1iF6qGDuKsBQ4ARBxOssxLK+tfV9mCKaIov0aR5o/L+m1 lCZow5VyGuDO58tUD6Ws5r6eO8kV56MgZh2BmlVdglR0N6/nHifWkwRbpYEp2JDrpWu6 6ExA== 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=WzCeD96mdqS8ayUSQrtfxYNv5qyDkHlLyxEuT5l/fk4=; b=AKNd6x5JBb9sHlud0hKGeNOdoXU0Yz0BlzpGzLM7OGKWBihph6oEI0l4sZCLbgJRxL TDCJO5IDssmNNkb74JOAyvn+L/67DMlByUCZvb51FmQ+7+eWowcmld90psqw4XtaLV7M g82e3LE6WYNyfZtodq7NGpK/usLmnOIUWJWY4xygoUmxXXrTZRVGNcEk3nGrAkf/Wv04 INd0gINASynQQtiihtAMr7/CZv4CL0PK+eRD5F9LFetNaPX36QJDoexOC5RGHgW0p+cD 5EdPESIqURRg9g/Nhn5RbSXTzu+/4XrTGFYQI7OUsZDJ2nORljC89kNKZcq759dBFHTb BEew== X-Gm-Message-State: AOAM532ECiu8SQ8drA49VugEpsnbqJQGKd4Nb/kZA9DlUuIsZcVcgur3 vrPYq+sGAM6GPz0CncKE8RjjlMRfRp3Pni16o6t1ag== X-Google-Smtp-Source: ABdhPJxeeAO6VIYn0Z7PLNib97Doh6SSR5Ainw252nWL4kSBny7EysZWtcPN1c4djHY9htqCGY4r1hbOcfcTf+GUv5w= X-Received: by 2002:a2e:a911:: with SMTP id j17mr16271349ljq.341.1627410709642; Tue, 27 Jul 2021 11:31:49 -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> In-Reply-To: From: Nick Desaulniers Date: Tue, 27 Jul 2021 11:31:38 -0700 Message-ID: Subject: Re: [PATCH v2 1/3] base: mark 'no_warn' as unused To: Greg Kroah-Hartman Cc: Bill Wendling , 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-toolchains@vger.kernel.org On Tue, Jul 27, 2021 at 10:59 AM Greg Kroah-Hartman wrote: > > On Tue, Jul 27, 2021 at 10:39:49AM -0700, Nick Desaulniers wrote: > > 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? There HAS to be that option somewhere anyway as we need > it for other parts of the kernel where we do: > write_bus(device, &value); > value = read_bus(device); > and then we ignore value as it is not needed, but yet we still HAVE to > call read_bus() here, yet read_bus() is set as warn_unused_result() > because, well, it is a read function :) Such wrappers are trivial with __attribute__((alias(""))): https://godbolt.org/z/j5afPbGcM At least then it's very obvious if someone adds more call sites to such an alias. Then that calls for closer inspection in code review that yes, this is one of those 0.01% of cases. Since they occur 0.01% of the time, I don't expect such aliases to occur too frequently. -- Thanks, ~Nick Desaulniers