* [Ocfs2-devel] [PATCH] ocfs2: Reomve err less than zero check
@ 2021-05-08 10:41 Jiapeng Chong
2021-05-10 2:10 ` Joseph Qi
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-05-08 10:41 UTC (permalink / raw)
To: mark; +Cc: Jiapeng Chong, ocfs2-devel, linux-kernel
The check for err < 0 is always false because err is an enum and can
never be less than zero.
Clean up the following coccicheck warning:
fs/ocfs2/dlm/dlmdebug.c:222 dlm_errname() warn: unsigned 'err' is never
less than zero.
fs/ocfs2/dlm/dlmdebug.c:214 dlm_errmsg() warn: unsigned 'err' is never
less than zero.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
fs/ocfs2/dlm/dlmdebug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
index d442cf5..817914d 100644
--- a/fs/ocfs2/dlm/dlmdebug.c
+++ b/fs/ocfs2/dlm/dlmdebug.c
@@ -211,7 +211,7 @@ void dlm_print_one_lock(struct dlm_lock *lockid)
const char *dlm_errmsg(enum dlm_status err)
{
- if (err >= DLM_MAXSTATS || err < 0)
+ if (err >= DLM_MAXSTATS)
return dlm_errmsgs[DLM_MAXSTATS];
return dlm_errmsgs[err];
}
@@ -219,7 +219,7 @@ const char *dlm_errmsg(enum dlm_status err)
const char *dlm_errname(enum dlm_status err)
{
- if (err >= DLM_MAXSTATS || err < 0)
+ if (err >= DLM_MAXSTATS)
return dlm_errnames[DLM_MAXSTATS];
return dlm_errnames[err];
}
--
1.8.3.1
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Ocfs2-devel] [PATCH] ocfs2: Reomve err less than zero check
2021-05-08 10:41 [Ocfs2-devel] [PATCH] ocfs2: Reomve err less than zero check Jiapeng Chong
@ 2021-05-10 2:10 ` Joseph Qi
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Qi @ 2021-05-10 2:10 UTC (permalink / raw)
To: Jiapeng Chong, mark; +Cc: ocfs2-devel, linux-kernel
On 5/8/21 6:41 PM, Jiapeng Chong wrote:
> The check for err < 0 is always false because err is an enum and can
> never be less than zero.
>
Precisely speaking, it is because enum dlm_status starts from 0.
So could you please update commit log and send v2?
Thanks,
Joseph
> Clean up the following coccicheck warning:
>
> fs/ocfs2/dlm/dlmdebug.c:222 dlm_errname() warn: unsigned 'err' is never
> less than zero.
>
> fs/ocfs2/dlm/dlmdebug.c:214 dlm_errmsg() warn: unsigned 'err' is never
> less than zero.
>
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> fs/ocfs2/dlm/dlmdebug.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ocfs2/dlm/dlmdebug.c b/fs/ocfs2/dlm/dlmdebug.c
> index d442cf5..817914d 100644
> --- a/fs/ocfs2/dlm/dlmdebug.c
> +++ b/fs/ocfs2/dlm/dlmdebug.c
> @@ -211,7 +211,7 @@ void dlm_print_one_lock(struct dlm_lock *lockid)
>
> const char *dlm_errmsg(enum dlm_status err)
> {
> - if (err >= DLM_MAXSTATS || err < 0)
> + if (err >= DLM_MAXSTATS)
> return dlm_errmsgs[DLM_MAXSTATS];
> return dlm_errmsgs[err];
> }
> @@ -219,7 +219,7 @@ const char *dlm_errmsg(enum dlm_status err)
>
> const char *dlm_errname(enum dlm_status err)
> {
> - if (err >= DLM_MAXSTATS || err < 0)
> + if (err >= DLM_MAXSTATS)
> return dlm_errnames[DLM_MAXSTATS];
> return dlm_errnames[err];
> }
>
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-10 2:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08 10:41 [Ocfs2-devel] [PATCH] ocfs2: Reomve err less than zero check Jiapeng Chong
2021-05-10 2:10 ` Joseph Qi
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).