fs/jffs2/readinode.c:189: faulty logic ?
Joakim Tjernlund
Joakim.Tjernlund at infinera.com
Tue Jan 24 07:11:41 PST 2017
On Tue, 2017-01-24 at 15:52 +0100, Marek Vasut wrote:
> On 01/24/2017 09:15 AM, David Binderman wrote:
> > Hello there,
> >
> > fs/jffs2/readinode.c:189]: (style) Condition 'tn.fn.ofs>=offset' is always true
> >
> > Source code is
> >
> > if (tn->fn->ofs < offset)
> > next = tn->rb.rb_right;
> > else if (tn->fn->ofs >= offset)
> > next = tn->rb.rb_left;
> > else
> > break;
> >
> > Maybe better code
> >
> > if (tn->fn->ofs < offset)
> > next = tn->rb.rb_right;
> > else if (tn->fn->ofs > offset)
> > next = tn->rb.rb_left;
> > else
> > break;
>
> This changes the logic of the code for equality case, please elaborate
> why this is OK.
There is something odd with current code:
next = tn_root->rb_node;
while (next) {
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;
}
The else break; is never reached so the above change makes the break work for ==
Weather this is correct or not I cannot say.
Jocke
More information about the linux-mtd
mailing list