All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Nathan Chancellor <nathan@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 16:02:26 +0100	[thread overview]
Message-ID: <Y6XDAiMAMLniR9PG@kroah.com> (raw)
In-Reply-To: <20221223145137.3786601-1-ammar.faizi@intel.com>

On Fri, Dec 23, 2022 at 09:51:37PM +0700, Ammar Faizi wrote:
> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> 
> Compiling with clang-16:
> 
>   drivers/base/module.c:36:6: error: variable 'no_warn' set but not \
>   used [-Werror,-Wunused-but-set-variable]
>           int no_warn;
>               ^
>   1 error generated.
> 
> A reason the @no_warn variable exists is:
> sysfs_create_link() return value needs not be ignored to silence
> another warning.
> 
> So don't remove @no_warn, but add a '(void)no_warn;'.
> 
> Cc: LLVM Mailing List <llvm@lists.linux.dev>
> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> ---
>  drivers/base/module.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/base/module.c b/drivers/base/module.c
> index 46ad4d636731..42f0b3b9e7f8 100644
> --- a/drivers/base/module.c
> +++ b/drivers/base/module.c
> @@ -59,22 +59,23 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
>  		return;
>  
>  	/* Don't check return codes; these calls are idempotent */
>  	no_warn = sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
>  	driver_name = make_driver_name(drv);
>  	if (driver_name) {
>  		module_create_drivers_dir(mk);
>  		no_warn = sysfs_create_link(mk->drivers_dir, &drv->p->kobj,
>  					    driver_name);
>  		kfree(driver_name);
>  	}
> +	(void)no_warn;

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.

sorry,

greg k-h

  reply	other threads:[~2022-12-23 15:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-23 14:51 [PATCH v1] driver core: Silence 'unused-but-set variable' warning Ammar Faizi
2022-12-23 15:02 ` Greg Kroah-Hartman [this message]
2022-12-23 15:31   ` Ammar Faizi
2022-12-23 17:31     ` Nathan Chancellor

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=Y6XDAiMAMLniR9PG@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=ammarfaizi2@gnuweeb.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.