mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	LLVM Mailing List <llvm@lists.linux.dev>
Subject: Re: [PATCH v1] driver core: Silence 'unused-but-set variable' warning
Date: Fri, 23 Dec 2022 10:31:08 -0700	[thread overview]
Message-ID: <Y6Xl3M7Tx+c2SCa9@dev-arch.thelio-3990X> (raw)
In-Reply-To: <7f61b046-c6f2-1dd6-98e9-e5b49b3c7dde@gnuweeb.org>

On Fri, Dec 23, 2022 at 10:31:57PM +0700, Ammar Faizi wrote:
> On 12/23/22 10:02 PM, Greg Kroah-Hartman wrote:
> > Ick, no, that's horrid and is NOT ok for kernel code, sorry.
> > 
> > Please fix the compiler, this is not a "fix" in any sense of the word
> > and is not going to work at all for kernel code.

It is possible that the compiler should not emit
-Wunused-but-set-variable when the variable is assigned the return
value of a function marked with __attribute__((warn_unused_result)) but
neither compiler does that today, you'll see the exact same warning from
GCC 12.2.0:

  drivers/base/module.c: In function ‘module_add_driver’:
  drivers/base/module.c:36:13: error: variable ‘no_warn’ set but not used [-Werror=unused-but-set-variable]
     36 |         int no_warn;
        |             ^~~~~~~
  cc1: all warnings being treated as errors

This has come up before too:

https://lore.kernel.org/20210726201924.3202278-2-morbo@google.com/

> Agree.
> 
> Sorry for the noise. It turned out I messed up my clang compiler flags.
> I forgot to do a "git reset --hard" before recompiling.
> 
> This has nothing todo with the upstream kernel.

This warning is in W=1, which are warnings that we want to turn on at
some point but the current instances need to be fixed first, so I would
say this is still relevant to the upstream kernel.

Cheers,
Nathan

      reply	other threads:[~2022-12-23 17:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-23 14:51 Ammar Faizi
2022-12-23 15:02 ` Greg Kroah-Hartman
2022-12-23 15:31   ` Ammar Faizi
2022-12-23 17:31     ` Nathan Chancellor [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6Xl3M7Tx+c2SCa9@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=ndesaulniers@google.com \
    --cc=rafael@kernel.org \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®