From: Mihai Moldovan <ionic@ionic.de>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] kconfig: nconf: stop endless search-up loops
Date: Sat, 10 Apr 2021 09:00:33 +0200 [thread overview]
Message-ID: <9e8d429f-c21c-7d9e-0dcd-8947846fe9ba@ionic.de> (raw)
In-Reply-To: <CAK7LNATzx9ujmapPbPzjL1Yo-A0RAXz0Kma+ve8pUeDDVx8GGw@mail.gmail.com>
* On 4/10/21 7:47 AM, Masahiro Yamada wrote:
> On Sun, Mar 28, 2021 at 6:52 PM Mihai Moldovan <ionic@ionic.de> wrote:
>> + if ((index == -1) && (index == match_start))
>> + return -1;
>
> We know 'index' is -1 in the second comparison.
> So, you can also write like this:
>
> if (match_start == -1 && index == -1)
> return -1;
I know, but I sided for the other form for semantic reasons - this more closely
directly describes what we actually care about (both being the same value and
either one being -1).
> But, it is not the correct fix, either.
>
> The root cause of the bug is match_start
> becoming -1.
>
>
> The following is the correct way to fix the bug
> without increasing the number of lines.
>
>
>
> diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
> index e0f965529166..af814b39b876 100644
> [...]
> + match_start = (match_start + items_num) % items_num;
> index = match_start;
> - index = (index + items_num) % items_num;
This is probably more elegant and fixes two issues at the same time: match_start
becoming -1 or n (which is likewise invalid, but was implicitly handled through
the remainder operation).
No objections from my side.
Mihai
next prev parent reply other threads:[~2021-04-10 7:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-27 12:01 [PATCH] " Mihai Moldovan
2021-03-27 15:58 ` Randy Dunlap
2021-03-27 22:12 ` Mihai Moldovan
2021-03-27 22:26 ` Randy Dunlap
2021-03-28 9:27 ` Mihai Moldovan
2021-03-28 10:37 ` Joe Perches
2021-03-28 10:32 ` Joe Perches
2021-03-28 16:16 ` Randy Dunlap
2021-03-28 9:52 ` [PATCH v2] " Mihai Moldovan
2021-04-10 5:47 ` Masahiro Yamada
2021-04-10 7:00 ` Mihai Moldovan [this message]
2021-04-10 9:12 ` Masahiro Yamada
2021-04-15 7:28 ` [PATCH v3] kconfig: nconf: stop endless search loops Mihai Moldovan
2021-04-16 5:40 ` Masahiro Yamada
2021-04-16 10:39 ` Mihai Moldovan
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=9e8d429f-c21c-7d9e-0dcd-8947846fe9ba@ionic.de \
--to=ionic@ionic.de \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.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
Powered by JetHome