From: Nicolas Schier <nicolas@fjasle.eu>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] kconfig: refactor conf_set_all_new_symbols() to reduce indentation level
Date: Wed, 5 Jun 2024 22:25:45 +0200 [thread overview]
Message-ID: <ZmDJya3X1rwtHteD@fjasle.eu> (raw)
In-Reply-To: <20240602125416.976336-2-masahiroy@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 2910 bytes --]
On Sun, Jun 02, 2024 at 09:54:15PM +0900 Masahiro Yamada wrote:
> The outer switch statement can be avoided by continue'ing earlier the
> loop when the symbol type is neither S_BOOLEAN nor S_TRISTATE.
>
> Remove it to reduce the indentation level by one. In addition, avoid
> the repetition of sym->def[S_DEF_USER].tri.
>
> No functional change intended.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
>
> scripts/kconfig/conf.c | 61 +++++++++++++++++++++---------------------
> 1 file changed, 30 insertions(+), 31 deletions(-)
>
> diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
> index 9a20e9e9bdad..cf8193fc00fc 100644
> --- a/scripts/kconfig/conf.c
> +++ b/scripts/kconfig/conf.c
> @@ -218,43 +218,42 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode)
> }
>
> for_all_symbols(sym) {
> - if (sym_has_value(sym) || sym->flags & SYMBOL_VALID)
> + tristate val;
> +
> + if (sym_has_value(sym) || sym->flags & SYMBOL_VALID ||
> + (sym->type != S_BOOLEAN && sym->type != S_TRISTATE))
> continue;
> - switch (sym_get_type(sym)) {
> - case S_BOOLEAN:
> - case S_TRISTATE:
> - has_changed = true;
> - switch (mode) {
> - case def_yes:
> - sym->def[S_DEF_USER].tri = yes;
> - break;
> - case def_mod:
> - sym->def[S_DEF_USER].tri = mod;
> - break;
> - case def_no:
> - sym->def[S_DEF_USER].tri = no;
> - break;
> - case def_random:
> - sym->def[S_DEF_USER].tri = no;
> - cnt = rand() % 100;
> - if (sym->type == S_TRISTATE) {
> - if (cnt < pty)
> - sym->def[S_DEF_USER].tri = yes;
> - else if (cnt < pty + ptm)
> - sym->def[S_DEF_USER].tri = mod;
> - } else if (cnt < pby)
> - sym->def[S_DEF_USER].tri = yes;
> - break;
> - default:
> - continue;
> +
> + has_changed = true;
> + switch (mode) {
> + case def_yes:
> + val = yes;
> + break;
> + case def_mod:
> + val = mod;
> + break;
> + case def_no:
> + val = no;
> + break;
> + case def_random:
> + val = no;
> + cnt = rand() % 100;
> + if (sym->type == S_TRISTATE) {
> + if (cnt < pty)
> + val = yes;
> + else if (cnt < pty + ptm)
> + val = mod;
> + } else if (cnt < pby) {
> + val = yes;
> }
> - if (!(sym_is_choice(sym) && mode == def_random))
> - sym->flags |= SYMBOL_DEF_USER;
> break;
> default:
> - break;
> + continue;
> }
> + sym->def[S_DEF_USER].tri = val;
>
> + if (!(sym_is_choice(sym) && mode == def_random))
> + sym->flags |= SYMBOL_DEF_USER;
> }
>
> sym_clear_all_valid();
> --
> 2.40.1
>
>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
--
epost|xmpp: nicolas@fjasle.eu irc://oftc.net/nsc
↳ gpg: 18ed 52db e34f 860e e9fb c82b 7d97 0932 55a0 ce7f
-- frykten for herren er opphav til kunnskap --
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-06-05 20:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-02 12:54 [PATCH 1/3] kconfig: remove tristate choice support Masahiro Yamada
2024-06-02 12:54 ` [PATCH 2/3] kconfig: refactor conf_set_all_new_symbols() to reduce indentation level Masahiro Yamada
2024-06-05 20:25 ` Nicolas Schier [this message]
2024-06-02 12:54 ` [PATCH 3/3] kconfig: refactor conf_write_defconfig() " Masahiro Yamada
2024-06-05 20:30 ` Nicolas Schier
2024-06-05 20:03 ` [PATCH 1/3] kconfig: remove tristate choice support Nicolas Schier
2024-06-06 6:57 ` Masahiro Yamada
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=ZmDJya3X1rwtHteD@fjasle.eu \
--to=nicolas@fjasle.eu \
--cc=linux-kbuild@vger.kernel.org \
--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