Skip to contentSkip to conversation

dm: remove unneeded variable

PATCH NAK [email protected] 3 participants 3 messages Nov 11, 2021 – Nov 12, 2021 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: remove unneeded variable

From: ran jianping <[email protected]>

Fix the following coccicheck review:
./drivers/md/dm-ps-round-robin.c:91:5-7:Unneeded variable

Remove unneeded variable used to store return value.

---
 drivers/md/dm-ps-round-robin.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-ps-round-robin.c +1 -2
index 27f44c5fa04e..455fc02af1cf 100644
@@ -88,7 +88,6 @@ static int rr_status(struct path_selector *ps, struct dm_path *path,
 		     status_type_t type, char *result, unsigned int maxlen)
 {
 	struct path_info *pi;
-	int sz = 0;
 
 	if (!path)
 		DMEMIT("0 ");
@@ -107,7 +106,7 @@ static int rr_status(struct path_selector *ps, struct dm_path *path,
 		}
 	}
 
-	return sz;
+	return 0;
 }
 
 /*
Signature · 1 line
2.25.1
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on device-mapper-dm/for-next]
[also build test ERROR on v5.15 next-20211111]
[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/cgel-zte-gmail-com/dm-remove-unneeded-variable/20211111-155437
base:   https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git for-next
config: i386-debian-10.3 (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/dbcfa76d0a7e2af056369733ed58150e479ec0c7
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/dm-remove-unneeded-variable/20211111-155437 git checkout dbcfa76d0a7e2af056369733ed58150e479ec0c7
# save the attached .config to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/md/

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

In file included from drivers/md/dm-ps-round-robin.c:12:
drivers/md/dm-ps-round-robin.c: In function 'rr_status':

>> include/linux/device-mapper.h:602:22: error: 'sz' undeclared (first use in this function); did you mean 's8'?
     602 | #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
         |                      ^~
   drivers/md/dm-ps-round-robin.c:93:3: note: in expansion of macro 'DMEMIT'
      93 |   DMEMIT("0 ");
         |   ^~~~~~
   include/linux/device-mapper.h:602:22: note: each undeclared identifier is reported only once for each function it appears in
     602 | #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
         |                      ^~
   drivers/md/dm-ps-round-robin.c:93:3: note: in expansion of macro 'DMEMIT'
      93 |   DMEMIT("0 ");
         |   ^~~~~~

vim +602 include/linux/device-mapper.h

0da336e5fab75c Alasdair G Kergon 2008-04-24 601
0da336e5fab75c Alasdair G Kergon 2008-04-24 @602 #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
0da336e5fab75c Alasdair G Kergon 2008-04-24 603 0 : scnprintf(result + sz, maxlen - sz, x))
0da336e5fab75c Alasdair G Kergon 2008-04-24 604

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

Nacked-by on v1 1/1 NAK
#2 lore raw
In reply to [email protected]
Quoted 37 lines · On Thu, Nov 11 2021 at 2:53P -0500, [email protected] <[email protected]>…

From: ran jianping <[email protected]>

Fix the following coccicheck review:
./drivers/md/dm-ps-round-robin.c:91:5-7:Unneeded variable

Remove unneeded variable used to store return value.

---
 drivers/md/dm-ps-round-robin.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-ps-round-robin.c +1 -2
index 27f44c5fa04e..455fc02af1cf 100644
@@ -88,7 +88,6 @@ static int rr_status(struct path_selector *ps, struct dm_path *path,
 		     status_type_t type, char *result, unsigned int maxlen)
 {
 	struct path_info *pi;
-	int sz = 0;
 
 	if (!path)
 		DMEMIT("0 ");
@@ -107,7 +106,7 @@ static int rr_status(struct path_selector *ps, struct dm_path *path,
 		}
 	}
 
-	return sz;
+	return 0;
 }
 
 /*
Signature · 1 line
2.25.1

You clearly didn't even compile test this (hint: DMEMIT macro uses it).