linux-6.16/fs/jffs2/readinode.c:189: loop can never finish

Zhihao Cheng chengzhihao1 at huawei.com
Mon Aug 4 00:10:35 PDT 2025


在 2025/8/4 14:23, David Binderman 写道:
> Hello there,
> 
> Static analyser cppcheck said:
> 
> linux-6.16/fs/jffs2/readinode.c:189:24: style: Expression is always true because 'else if' condition is opposite to previous condition at line 187. [multiCondition]
> 
> Source code is
> 
>      while (next) {

Hi,
The 'next != NULL' is also a condition for the loop, this snippet of 
code finds a leaf node in 'tn_root'.
>          tn = rb_entry(next, struct jffs2_tmp_dnode_info, rb);
> 
>          if (tn->fn->ofs < offset)
>              next = tn->rb.rb_right;
>          else if (tn->fn->ofs >= offset)
>              next = tn->rb.rb_left;
>          else
>              break;
>      }
> 
> It looks to me like this loop will never finish.
> Suggest change ">=" to ">".
> 
> Regards
> 
> David Binderman
> 
> 
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
> .
> 




More information about the linux-mtd mailing list