Linux-Modules Archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
	linux-modules@vger.kernel.org,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] module: silence warning about unused 'no_warn' variable
Date: Fri, 22 Mar 2024 14:20:05 +0100	[thread overview]
Message-ID: <20240322132014.906097-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

The sysfs_create_link() return code is marked as __must_check, but the
module_add_driver() function tries hard to not care, by assigning the
return code to a variable. When building with 'make W=1', gcc still
warns because this variable is only assigned but not used:

drivers/base/module.c: In function 'module_add_driver':
drivers/base/module.c:36:6: warning: variable 'no_warn' set but not used [-Wunused-but-set-variable]

Add an explicit cast to void to prevent this check as well.

Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: linux-modules@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Fixes: e17e0f51aeea ("Driver core: show drivers in /sys/module/")
See-also: 4a7fb6363f2d ("add __must_check to device management code")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I'm not entirely sure what bug the __must_check on sysfs_create_link()
is trying to prevent, or why the module loader code is allowed to
ignore this. It would be nice to have an Ack from the sysfs maintainers
on this.
---
 drivers/base/module.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/base/module.c b/drivers/base/module.c
index 46ad4d636731..0180dbcf2240 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -67,6 +67,8 @@ void module_add_driver(struct module *mod, struct device_driver *drv)
 					    driver_name);
 		kfree(driver_name);
 	}
+
+	(void)no_warn;
 }
 
 void module_remove_driver(struct device_driver *drv)
-- 
2.39.2


             reply	other threads:[~2024-03-22 13:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-22 13:20 Arnd Bergmann [this message]
2024-03-22 13:47 ` [PATCH] module: silence warning about unused 'no_warn' variable Greg Kroah-Hartman

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=20240322132014.906097-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=rafael@kernel.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).