2020-04-22 07:14:29

by Wu Bo

[permalink] [raw]
Subject: [PATCH] fs:ocfs2:remove unneeded variable 'o2dlm_flags'

Fix the following coccicheck warning:
fs/ocfs2/stack_o2cb.c:69:5-16: Unneeded variable: "o2dlm_flags".
Return "0" on line 84

Signed-off-by: Wu Bo <[email protected]>
---
fs/ocfs2/stack_o2cb.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index dbf8b57..2da9633 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -66,8 +66,6 @@ static inline int mode_to_o2dlm(int mode)
}
static int flags_to_o2dlm(u32 flags)
{
- int o2dlm_flags = 0;
-
map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
map_flag(DLM_LKF_CANCEL, LKM_CANCEL);
map_flag(DLM_LKF_CONVERT, LKM_CONVERT);
@@ -81,7 +79,7 @@ static int flags_to_o2dlm(u32 flags)
/* map_flag() should have cleared every flag passed in */
BUG_ON(flags != 0);

- return o2dlm_flags;
+ return 0;
}
#undef map_flag

--
1.8.3.1


2020-04-22 07:55:36

by Joseph Qi

[permalink] [raw]
Subject: Re: [PATCH] fs:ocfs2:remove unneeded variable 'o2dlm_flags'



On 2020/4/22 15:12, Wu Bo wrote:
> Fix the following coccicheck warning:
> fs/ocfs2/stack_o2cb.c:69:5-16: Unneeded variable: "o2dlm_flags".
> Return "0" on line 84
>
Umm... This is not right, NAK.
Something tricky is in map_flag() so that coccicheck doesn't recognize.

Thanks,
Joseph

> Signed-off-by: Wu Bo <[email protected]>
> ---
> fs/ocfs2/stack_o2cb.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
> index dbf8b57..2da9633 100644
> --- a/fs/ocfs2/stack_o2cb.c
> +++ b/fs/ocfs2/stack_o2cb.c
> @@ -66,8 +66,6 @@ static inline int mode_to_o2dlm(int mode)
> }
> static int flags_to_o2dlm(u32 flags)
> {
> - int o2dlm_flags = 0;
> -
> map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
> map_flag(DLM_LKF_CANCEL, LKM_CANCEL);
> map_flag(DLM_LKF_CONVERT, LKM_CONVERT);
> @@ -81,7 +79,7 @@ static int flags_to_o2dlm(u32 flags)
> /* map_flag() should have cleared every flag passed in */
> BUG_ON(flags != 0);
>
> - return o2dlm_flags;
> + return 0;
> }
> #undef map_flag
>
>

2020-04-22 08:05:00

by Wu Bo

[permalink] [raw]
Subject: Re: [PATCH] fs:ocfs2:remove unneeded variable 'o2dlm_flags'

On 2020/4/22 15:52, Joseph Qi wrote:
>
>
> On 2020/4/22 15:12, Wu Bo wrote:
>> Fix the following coccicheck warning:
>> fs/ocfs2/stack_o2cb.c:69:5-16: Unneeded variable: "o2dlm_flags".
>> Return "0" on line 84
>>
> Umm... This is not right, NAK.
> Something tricky is in map_flag() so that coccicheck doesn't recognize.
>
> Thanks,
> Joseph

You are right. Did not notice that map_flag is a macro, Please ignore
this patch.

Thanks,
Wu Bo

>
>> Signed-off-by: Wu Bo <[email protected]>
>> ---
>> fs/ocfs2/stack_o2cb.c | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
>> index dbf8b57..2da9633 100644
>> --- a/fs/ocfs2/stack_o2cb.c
>> +++ b/fs/ocfs2/stack_o2cb.c
>> @@ -66,8 +66,6 @@ static inline int mode_to_o2dlm(int mode)
>> }
>> static int flags_to_o2dlm(u32 flags)
>> {
>> - int o2dlm_flags = 0;
>> -
>> map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
>> map_flag(DLM_LKF_CANCEL, LKM_CANCEL);
>> map_flag(DLM_LKF_CONVERT, LKM_CONVERT);
>> @@ -81,7 +79,7 @@ static int flags_to_o2dlm(u32 flags)
>> /* map_flag() should have cleared every flag passed in */
>> BUG_ON(flags != 0);
>>
>> - return o2dlm_flags;
>> + return 0;
>> }
>> #undef map_flag
>>
>>
>
> .
>


2020-04-24 18:25:37

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] fs:ocfs2:remove unneeded variable 'o2dlm_flags'

Hi Wu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.7-rc2 next-20200424]
[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/Wu-Bo/fs-ocfs2-remove-unneeded-variable-o2dlm_flags/20200424-014056
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 18bf34080c4c3beb6699181986cc97dd712498fe
config: sh-allmodconfig (attached as .config)
compiler: sh4-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=sh

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 >>):

fs/ocfs2/stack_o2cb.c: In function 'flags_to_o2dlm':
>> fs/ocfs2/stack_o2cb.c:65:3: error: 'o2dlm_flags' undeclared (first use in this function)
65 | o2dlm_flags |= (_o2dlm); \
| ^~~~~~~~~~~
>> fs/ocfs2/stack_o2cb.c:69:2: note: in expansion of macro 'map_flag'
69 | map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
| ^~~~~~~~
fs/ocfs2/stack_o2cb.c:65:3: note: each undeclared identifier is reported only once for each function it appears in
65 | o2dlm_flags |= (_o2dlm); \
| ^~~~~~~~~~~
>> fs/ocfs2/stack_o2cb.c:69:2: note: in expansion of macro 'map_flag'
69 | map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
| ^~~~~~~~

vim +/o2dlm_flags +65 fs/ocfs2/stack_o2cb.c

e3dad42bf993a0 Joel Becker 2008-02-01 61
e3dad42bf993a0 Joel Becker 2008-02-01 62 #define map_flag(_generic, _o2dlm) \
e3dad42bf993a0 Joel Becker 2008-02-01 63 if (flags & (_generic)) { \
e3dad42bf993a0 Joel Becker 2008-02-01 64 flags &= ~(_generic); \
e3dad42bf993a0 Joel Becker 2008-02-01 @65 o2dlm_flags |= (_o2dlm); \
e3dad42bf993a0 Joel Becker 2008-02-01 66 }
e3dad42bf993a0 Joel Becker 2008-02-01 67 static int flags_to_o2dlm(u32 flags)
e3dad42bf993a0 Joel Becker 2008-02-01 68 {
e3dad42bf993a0 Joel Becker 2008-02-01 @69 map_flag(DLM_LKF_NOQUEUE, LKM_NOQUEUE);
e3dad42bf993a0 Joel Becker 2008-02-01 70 map_flag(DLM_LKF_CANCEL, LKM_CANCEL);
e3dad42bf993a0 Joel Becker 2008-02-01 71 map_flag(DLM_LKF_CONVERT, LKM_CONVERT);
e3dad42bf993a0 Joel Becker 2008-02-01 72 map_flag(DLM_LKF_VALBLK, LKM_VALBLK);
e3dad42bf993a0 Joel Becker 2008-02-01 73 map_flag(DLM_LKF_IVVALBLK, LKM_INVVALBLK);
e3dad42bf993a0 Joel Becker 2008-02-01 74 map_flag(DLM_LKF_ORPHAN, LKM_ORPHAN);
e3dad42bf993a0 Joel Becker 2008-02-01 75 map_flag(DLM_LKF_FORCEUNLOCK, LKM_FORCE);
e3dad42bf993a0 Joel Becker 2008-02-01 76 map_flag(DLM_LKF_TIMEOUT, LKM_TIMEOUT);
e3dad42bf993a0 Joel Becker 2008-02-01 77 map_flag(DLM_LKF_LOCAL, LKM_LOCAL);
e3dad42bf993a0 Joel Becker 2008-02-01 78
e3dad42bf993a0 Joel Becker 2008-02-01 79 /* map_flag() should have cleared every flag passed in */
e3dad42bf993a0 Joel Becker 2008-02-01 80 BUG_ON(flags != 0);
e3dad42bf993a0 Joel Becker 2008-02-01 81
54d663085a6a0f Wu Bo 2020-04-22 82 return 0;
e3dad42bf993a0 Joel Becker 2008-02-01 83 }
e3dad42bf993a0 Joel Becker 2008-02-01 84 #undef map_flag
e3dad42bf993a0 Joel Becker 2008-02-01 85

:::::: The code at line 65 was first introduced by commit
:::::: e3dad42bf993a0f24eb6e46152356c9b119c15e8 ocfs2: Create ocfs2_stack_operations and split out the o2cb stack.

:::::: TO: Joel Becker <[email protected]>
:::::: CC: Mark Fasheh <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (3.95 kB)
.config.gz (53.36 kB)
Download all attachments