mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: David Binderman <dcb314@hotmail.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"richard@nod.at" <richard@nod.at>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: linux-6.16/fs/jffs2/readinode.c:189: loop can never finish
Date: Mon, 4 Aug 2025 15:10:35 +0800	[thread overview]
Message-ID: <df923d94-92ee-f824-01e2-21e6ed3d593c@huawei.com> (raw)
In-Reply-To: <AS8PR02MB10217F68E5D37ECD491495E669C23A@AS8PR02MB10217.eurprd02.prod.outlook.com>

在 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/
> .
> 


  reply	other threads:[~2025-08-04  7:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-04  6:23 David Binderman
2025-08-04  7:10 ` Zhihao Cheng [this message]
2025-08-04  7:30   ` David Oberhollenzer
2025-08-04 10:54     ` 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=df923d94-92ee-f824-01e2-21e6ed3d593c@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=dcb314@hotmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    /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®