driver core: Remove set but not used variable 'no_warn'
PATCH 1/1 driver core: Remove set but not used variable 'no_warn'
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/base/module.c: In function 'module_create_drivers_dir':drivers/base/module.c:36:6: warning:
variable ‘no_warn’ set but not used [-Wunused-but-set-variable]
It never used since introduction.
--- drivers/base/module.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/base/module.c +3 -4
@@ -33,7 +33,6 @@ static void module_create_drivers_dir(struct module_kobject *mk)void module_add_driver (struct module *mod,struct device_driver *drv) {char *driver_name; -int no_warn;struct module_kobject *mk =NULL ;if (!drv)
@@ -59,12 +58,12 @@ 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" ); +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); +sysfs_create_link (mk->drivers_dir, &drv->p->kobj, + driver_name);kfree (driver_name); } }
Signature · 1 line
2.25.4
Greg KH
maintainerQuoted 44 lines · Baokun Li
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/base/module.c: In function 'module_create_drivers_dir':drivers/base/module.c:36:6: warning:
variable ‘no_warn’ set but not used [-Wunused-but-set-variable]It never used since introduction.
Signed-off-by Baokun Li <[email protected]>--- drivers/base/module.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/base/module.c +3
-4@@ -33,7 +33,6 @@ static void module_create_drivers_dir(struct module_kobject *mk)void module_add_driver (struct module *mod,struct device_driver *drv) {char *driver_name; -int no_warn;struct module_kobject *mk =NULL ;if (!drv)@@ -59,12 +58,12 @@ 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" ); +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); +sysfs_create_link (mk->drivers_dir, &drv->p->kobj, + driver_name);kfree (driver_name); } }Signature · 1 line
2.25.4
And now you have a build warning :(
Please always test-build your patches before sending them out.
greg k-h
kernel test robot
build botThank you for the patch! Perhaps something to improve:
Hi Baokun,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on next-20210526]
url: https://github.com/0day-ci/linux/commits/Baokun-Li/driver-core-Remove-set-but-not-used-variable-no_warn/20210527-170758 base: f6b46ef27317b3441138b902689bd89e4f82c6f4 config: um-x86_64_defconfig (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/c41d30a4b7791bb76211dd1ddb7b467d555ad596 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Baokun-Li/driver-core-Remove-set-but-not-used-variable-no_warn/20210527-170758 git checkout c41d30a4b7791bb76211dd1ddb7b467d555ad596 # save the attached .config to linux build tree make W=1 ARCH=um SUBARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
drivers/base/module.c: In function 'module_add_driver':
>> drivers/base/module.c:61:2: warning: ignoring return value of 'sysfs_create_link', declared with attribute warn_unused_result [-Wunused-result]
61 | sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/base/module.c:65:3: warning: ignoring return value of 'sysfs_create_link', declared with attribute warn_unused_result [-Wunused-result]
65 | sysfs_create_link(mk->drivers_dir, &drv->p->kobj,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66 | driver_name);
| ~~~~~~~~~~~~vim +/sysfs_create_link +61 drivers/base/module.c
32
33 void module_add_driver(struct module *mod, struct device_driver *drv)
34 {
35 char *driver_name;
36 struct module_kobject *mk = NULL;
37
38 if (!drv)
39 return;
40
41 if (mod)
42 mk = &mod->mkobj;
43 else if (drv->mod_name) {
44 struct kobject *mkobj;
45
46 /* Lookup built-in module entry in /sys/modules */
47 mkobj = kset_find_obj(module_kset, drv->mod_name);
48 if (mkobj) {
49 mk = container_of(mkobj, struct module_kobject, kobj);
50 /* remember our module structure */
51 drv->p->mkobj = mk;
52 /* kset_find_obj took a reference */
53 kobject_put(mkobj);
54 }
55 }
56
57 if (!mk)
58 return;
59
60 /* Don't check return codes; these calls are idempotent */
> 61 sysfs_create_link(&drv->p->kobj, &mk->kobj, "module");
62 driver_name = make_driver_name(drv);
63 if (driver_name) {
64 module_create_drivers_dir(mk);
65 sysfs_create_link(mk->drivers_dir, &drv->p->kobj,
66 driver_name);
67 kfree(driver_name);
68 }
69 }
70 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org