This patch fixes below warning reported by coccicheck:
drivers/md/dm-historical-service-time.c:240:14-16: Unneeded variable: "sz". Return "0" on line 261
Reported-by: Hulk Robot <[email protected]>
Signed-off-by: Samuel Zou <[email protected]>
---
drivers/md/dm-historical-service-time.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/dm-historical-service-time.c b/drivers/md/dm-historical-service-time.c
index 186f91e..3c8acb9 100644
--- a/drivers/md/dm-historical-service-time.c
+++ b/drivers/md/dm-historical-service-time.c
@@ -237,7 +237,6 @@ static void hst_destroy(struct path_selector *ps)
static int hst_status(struct path_selector *ps, struct dm_path *path,
status_type_t type, char *result, unsigned int maxlen)
{
- unsigned int sz = 0;
struct path_info *pi;
if (!path) {
@@ -258,7 +257,7 @@ static int hst_status(struct path_selector *ps, struct dm_path *path,
}
}
- return sz;
+ return 0;
}
static int hst_add_path(struct path_selector *ps, struct dm_path *path,
--
2.6.2
On Thu, May 07 2020 at 8:26am -0400,
Samuel Zou <[email protected]> wrote:
> This patch fixes below warning reported by coccicheck:
>
> drivers/md/dm-historical-service-time.c:240:14-16: Unneeded variable: "sz". Return "0" on line 261
>
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Samuel Zou <[email protected]>
Nack.
DMEMIT() uses the local sz variable.
Hi Mike,
You are right.
I did not notice that the macro DMEMIT uses the sz variable.
Thanks.
On 2020/5/7 22:29, Mike Snitzer wrote:
> On Thu, May 07 2020 at 8:26am -0400,
> Samuel Zou <[email protected]> wrote:
>
>> This patch fixes below warning reported by coccicheck:
>>
>> drivers/md/dm-historical-service-time.c:240:14-16: Unneeded variable: "sz". Return "0" on line 261
>>
>> Reported-by: Hulk Robot <[email protected]>
>> Signed-off-by: Samuel Zou <[email protected]>
>
> Nack.
>
> DMEMIT() uses the local sz variable.
>
>
Hi Samuel,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on next-20200507]
[also build test ERROR on dm/for-next]
[cannot apply to v5.7-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Samuel-Zou/dm-mpath-Remove-unused-variable-ret/20200508-031551
base: 6b43f715b6379433e8eb30aa9bcc99bd6a585f77
config: alpha-allyesconfig (attached as .config)
compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce:
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 GCC_VERSION=9.3.0 make.cross ARCH=alpha
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>
All error/warnings (new ones prefixed by >>):
In file included from drivers/md/dm.h:14,
from drivers/md/dm-historical-service-time.c:24:
drivers/md/dm-historical-service-time.c: In function 'hst_status':
>> include/linux/device-mapper.h:570:22: error: 'sz' undeclared (first use in this function); did you mean 's'?
570 | #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
| ^~
>> drivers/md/dm-historical-service-time.c:245:3: note: in expansion of macro 'DMEMIT'
245 | DMEMIT("2 %u %u ", s->weights[0], s->threshold_multiplier);
| ^~~~~~
include/linux/device-mapper.h:570:22: note: each undeclared identifier is reported only once for each function it appears in
570 | #define DMEMIT(x...) sz += ((sz >= maxlen) ? \
| ^~
>> drivers/md/dm-historical-service-time.c:245:3: note: in expansion of macro 'DMEMIT'
245 | DMEMIT("2 %u %u ", s->weights[0], s->threshold_multiplier);
| ^~~~~~
vim +/DMEMIT +245 drivers/md/dm-historical-service-time.c
580d206a4321a1 Khazhismel Kumykov 2020-04-30 236
580d206a4321a1 Khazhismel Kumykov 2020-04-30 237 static int hst_status(struct path_selector *ps, struct dm_path *path,
580d206a4321a1 Khazhismel Kumykov 2020-04-30 238 status_type_t type, char *result, unsigned int maxlen)
580d206a4321a1 Khazhismel Kumykov 2020-04-30 239 {
580d206a4321a1 Khazhismel Kumykov 2020-04-30 240 struct path_info *pi;
580d206a4321a1 Khazhismel Kumykov 2020-04-30 241
580d206a4321a1 Khazhismel Kumykov 2020-04-30 242 if (!path) {
580d206a4321a1 Khazhismel Kumykov 2020-04-30 243 struct selector *s = ps->context;
580d206a4321a1 Khazhismel Kumykov 2020-04-30 244
580d206a4321a1 Khazhismel Kumykov 2020-04-30 @245 DMEMIT("2 %u %u ", s->weights[0], s->threshold_multiplier);
580d206a4321a1 Khazhismel Kumykov 2020-04-30 246 } else {
580d206a4321a1 Khazhismel Kumykov 2020-04-30 247 pi = path->pscontext;
580d206a4321a1 Khazhismel Kumykov 2020-04-30 248
580d206a4321a1 Khazhismel Kumykov 2020-04-30 249 switch (type) {
580d206a4321a1 Khazhismel Kumykov 2020-04-30 250 case STATUSTYPE_INFO:
580d206a4321a1 Khazhismel Kumykov 2020-04-30 251 DMEMIT("%llu %llu %llu ", pi->historical_service_time,
580d206a4321a1 Khazhismel Kumykov 2020-04-30 252 pi->outstanding, pi->stale_after);
580d206a4321a1 Khazhismel Kumykov 2020-04-30 253 break;
580d206a4321a1 Khazhismel Kumykov 2020-04-30 254 case STATUSTYPE_TABLE:
580d206a4321a1 Khazhismel Kumykov 2020-04-30 255 DMEMIT("0 ");
580d206a4321a1 Khazhismel Kumykov 2020-04-30 256 break;
580d206a4321a1 Khazhismel Kumykov 2020-04-30 257 }
580d206a4321a1 Khazhismel Kumykov 2020-04-30 258 }
580d206a4321a1 Khazhismel Kumykov 2020-04-30 259
356072d04813ba Samuel Zou 2020-05-07 260 return 0;
580d206a4321a1 Khazhismel Kumykov 2020-04-30 261 }
580d206a4321a1 Khazhismel Kumykov 2020-04-30 262
:::::: The code at line 245 was first introduced by commit
:::::: 580d206a4321a146ef4637f14f2fc6d0d5c72c12 dm mpath: add Historical Service Time Path Selector
:::::: TO: Khazhismel Kumykov <[email protected]>
:::::: CC: Mike Snitzer <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]