* [PATCH v1] driver core: Silence 'unused-but-set variable' warning
@ 2022-12-23 14:51 Ammar Faizi
0 siblings, 0 replies; only message in thread
From: Ammar Faizi @ 2022-12-23 14:51 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Ammar Faizi, Rafael J. Wysocki, Linux Kernel Mailing List,
Nathan Chancellor, Nick Desaulniers, Tom Rix, LLVM Mailing List
From: Ammar Faizi <[email protected]>
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 <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
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;
}
void module_remove_driver(struct device_driver *drv)
{
struct module_kobject *mk = NULL;
char *driver_name;
if (!drv)
return;
sysfs_remove_link(&drv->p->kobj, "module");
base-commit: 8395ae05cb5a2e31d36106e8c85efa11cda849be
--
Ammar Faizi
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-12-23 14:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-23 14:51 [PATCH v1] driver core: Silence 'unused-but-set variable' warning Ammar Faizi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox