linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tipc: remove set but not used variable 'no_warn'
@ 2020-07-21  8:40 Zheng Yongjun
  2020-07-21 10:36 ` Greg KH
  2020-07-24 11:54 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Zheng Yongjun @ 2020-07-21  8:40 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Zheng Yongjun

Fixes gcc '-Wunused-but-set-variable' warning:

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

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
 drivers/base/module.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/base/module.c b/drivers/base/module.c
index 46ad4d636731..d1060c504c1b 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,11 +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,
+		sysfs_create_link(mk->drivers_dir, &drv->p->kobj,
 					    driver_name);
 		kfree(driver_name);
 	}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tipc: remove set but not used variable 'no_warn'
  2020-07-21  8:40 [PATCH] tipc: remove set but not used variable 'no_warn' Zheng Yongjun
@ 2020-07-21 10:36 ` Greg KH
  2020-07-24 11:54 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2020-07-21 10:36 UTC (permalink / raw)
  To: Zheng Yongjun; +Cc: rafael, linux-kernel

On Tue, Jul 21, 2020 at 04:40:23PM +0800, Zheng Yongjun wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
> 
> drivers/base/module.c: In function 'module_add_driver':
> drivers/base/module.c:33: warning:
> variable 'no_warn' set but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
>  drivers/base/module.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/base/module.c b/drivers/base/module.c
> index 46ad4d636731..d1060c504c1b 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,11 +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");

Always test-build your patches before sending them out :(


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tipc: remove set but not used variable 'no_warn'
  2020-07-21  8:40 [PATCH] tipc: remove set but not used variable 'no_warn' Zheng Yongjun
  2020-07-21 10:36 ` Greg KH
@ 2020-07-24 11:54 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-07-24 11:54 UTC (permalink / raw)
  To: Zheng Yongjun, gregkh, rafael; +Cc: kbuild-all, linux-kernel, Zheng Yongjun

[-- Attachment #1: Type: text/plain, Size: 3167 bytes --]

Hi Zheng,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on driver-core/driver-core-testing]
[also build test WARNING on v5.8-rc6 next-20200723]
[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/Zheng-Yongjun/tipc-remove-set-but-not-used-variable-no_warn/20200721-164445
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 6bdb486c5a628f7a927c2658166e3a5ef1f883e7
config: mips-randconfig-r004-20200724 (attached as .config)
compiler: mips-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
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips 

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,
         |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      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@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 21422 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-24 12:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21  8:40 [PATCH] tipc: remove set but not used variable 'no_warn' Zheng Yongjun
2020-07-21 10:36 ` Greg KH
2020-07-24 11:54 ` kernel test robot

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 NNTP newsgroup(s).