Re: [Ocfs2-devel] [PATCH v2] ocfs2: Reomve err less than zero check
From: Joseph Qi
Date: Mon May 10 2021 - 22:16:51 EST
On 5/10/21 11:50 PM, Wengang Wang wrote:
> Hi Jiapeng,
>
> Though the type of enum dlm_status has a value range starting from zero, It can be assigned with negative values without warnings.
> I am wondering why you are sure it can’t be negative? You went over all the calling path and so you are sure it can’t be negative?
> If you did that, I’d think/guess you should also be able to say it can’t be DLM_MAXSTATS or bigger, right? If not, which calling path are returning >= DLM_MAXSTATS value?
> we should fix that too.
>
> I’d think we should treat the two conditions of (err >= DLM_MAXSTATS) and the (err < 0) the same way. If keep, keep both. if remove, remove both.
> I’m suspecting the coccicheck warning is based on the type of enum (starting with 0), but if that’s the only theory to remove (err < 0), It’s NAK from me
DLM_MAXSTATS is a valid value for dlm_status.
Take a look again, I agree with Wengang that we'd better keep the check
here for those misused return code.
Thanks,
Joseph