Re: fs/jffs2/readinode.c:189: faulty logic ?
From: David Woodhouse
Date: Tue Jan 24 2017 - 19:36:43 EST
On Tue, 2017-01-24 at 08:15 +0000, 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;
Thanks for pointing this out; it looks like a correct fix at first.
However, it might expose a bug, if the 'break' case isn't particularly
well-tested. The existing bug is probably fairly harmless, while the
hypothetical new one isn't. So we need to take a closer look at the
surrounding code and ideally test it...
--Â
dwmw2Attachment:
smime.p7s
Description: S/MIME cryptographic signature