mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marek Vasut <marek.vasut@gmail.com>
To: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"dcb314@hotmail.com" <dcb314@hotmail.com>
Subject: Re: fs/jffs2/readinode.c:189: faulty logic ?
Date: Tue, 24 Jan 2017 16:14:02 +0100	[thread overview]
Message-ID: <87d819b7-8267-7d43-67b0-56c437c9290e@gmail.com> (raw)
In-Reply-To: <1485270700.4044.89.camel@infinera.com>

On 01/24/2017 04:11 PM, Joakim Tjernlund wrote:
> 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.

Indeed, I agree with this one. This is why I asked for more detailed
explanation too :)

-- 
Best regards,
Marek Vasut

  reply	other threads:[~2017-01-24 15:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <VI1PR08MB1022F25C7F26E465355F07149C750@VI1PR08MB1022.eurprd08.prod.outlook.com>
2017-01-24 14:52 ` Marek Vasut
2017-01-24 15:11   ` Joakim Tjernlund
2017-01-24 15:14     ` Marek Vasut [this message]
     [not found]   ` <VI1PR08MB1022B30CF5D9834EC9304F0F9C750@VI1PR08MB1022.eurprd08.prod.outlook.com>
2017-01-24 19:59     ` Marek Vasut
2017-01-24 22:20 ` Richard Weinberger
     [not found]   ` <VI1PR08MB1022FF07BD9A4B08984561FE9C750@VI1PR08MB1022.eurprd08.prod.outlook.com>
2017-01-25  8:31     ` Richard Weinberger
2017-01-24 23:30 ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d819b7-8267-7d43-67b0-56c437c9290e@gmail.com \
    --to=marek.vasut@gmail.com \
    --cc=Joakim.Tjernlund@infinera.com \
    --cc=dcb314@hotmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®