diff mbox series

[1/3] base: remove unused variable 'no_warn'

Message ID 20210714091747.2814370-2-morbo@google.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series Fix clang -Wunused-but-set-variable warnings | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 2 maintainers not CCed: gregkh@linuxfoundation.org rafael@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 21 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/header_inline success Link

Commit Message

Bill Wendling July 14, 2021, 9:17 a.m. UTC
Fix the following build warning:

  drivers/base/module.c:36:6: error: variable 'no_warn' set but not used [-Werror,-Wunused-but-set-variable]
        int no_warn;

Signed-off-by: Bill Wendling <morbo@google.com>
---
 drivers/base/module.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

kernel test robot July 14, 2021, 12:15 p.m. UTC | #1
Hi Bill,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on linux/master driver-core/driver-core-testing mkp-scsi/for-next ipvs/master linus/master v5.14-rc1 next-20210714]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Bill-Wendling/Fix-clang-Wunused-but-set-variable-warnings/20210714-172029
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: powerpc-redwood_defconfig (attached as .config)
compiler: powerpc-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/f6c4b007fc8c907719d883faae424f2cf3bb100c
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Bill-Wendling/Fix-clang-Wunused-but-set-variable-warnings/20210714-172029
        git checkout f6c4b007fc8c907719d883faae424f2cf3bb100c
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

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, 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, driver_name);
    66			kfree(driver_name);
    67		}
    68	}
    69	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/base/module.c b/drivers/base/module.c
index 46ad4d636731..81d84a066a38 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -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,11 @@  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);
 	}
 }