From: Nicolas Schier <nicolas@fjasle.eu>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
Matt Porter <mporter@kernel.crashing.org>,
Alexandre Bounine <alex.bou9@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Nathan Chancellor <nathan@kernel.org>,
linux-doc@vger.kernel.org
Subject: Re: [PATCH 2/2] kconfig: do not imply the type of choice from the first entry
Date: Tue, 7 May 2024 10:45:00 +0200 [thread overview]
Message-ID: <ZjnqDCqRLWmvFxWN@buildd.core.avm.de> (raw)
In-Reply-To: <20240427104231.2728905-3-masahiroy@kernel.org>
On Sat, Apr 27, 2024 at 07:42:31PM +0900, Masahiro Yamada wrote:
> The followng two test cases are very similar, but the latter does not
> work.
>
> [test case 1]
>
> choice
> prompt "choose"
>
> config A
> bool "A"
>
> if y
> config B
> bool "B"
> endif
>
> endchoice
>
> [test case 2]
>
> choice
> prompt "choose"
>
> if y
> config A
> bool "A"
>
> config B
> bool "B"
> endif
>
> endchoice
>
> Since 'if y' is always true, both of them should be equivalent to:
>
> choice
> prompt "choose"
>
> config A
> bool "A"
>
> config B
> bool "B"
>
> endchoice
>
> However, the test case 2 warns:
> Kconfig:1:warning: config symbol defined without type
>
> If the type of choice is not specified, it is implied from the first
> entry within the choice block.
>
> When inferring the choice type, menu_finalize() checks only direct
> children of the choice. At this point, the menu entries still exist
> under the 'if' entry:
>
> choice
> \-- if y
> |-- A
> \-- B
>
> Later, menu_finalize() re-parents the menu, so A and B will be lifted up
> right under the choice:
>
> choice
> |-- if y
> |-- A
> \-- B
>
> This is complex because menu_finalize() sets attributes, restructures
> the menu tree, and checks the sanity at the same time, leading to some
> bugs.
>
> It would be possible to resolve it by setting the choice type after
> re-parenting, but the current mechanism looks questionable to me.
>
> Let's default all choices to 'bool' unless the type is specified.
> This change makes sense because 99% of choice use cases are bool.
>
> There exists only one 'tristate' choice in drivers/rapidio/Kconfig.
> Another (much cleaner) approach would be to remove the tristate choice
> support entirely, but I have not yet made up my mind.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
Thanks, looks good to me.
Reviewed-by: Nicolas Schier <n.schier@avm.de>
prev parent reply other threads:[~2024-05-07 8:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 10:42 [PATCH 0/2] kconfig: stop implification of choice type Masahiro Yamada
2024-04-27 10:42 ` [PATCH 2/2] kconfig: do not imply the type of choice from the first entry Masahiro Yamada
2024-05-07 8:45 ` Nicolas Schier [this message]
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=ZjnqDCqRLWmvFxWN@buildd.core.avm.de \
--to=nicolas@fjasle.eu \
--cc=alex.bou9@gmail.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=mporter@kernel.crashing.org \
--cc=nathan@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).