From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Matt Porter <mporter@kernel.crashing.org>,
Alexandre Bounine <alex.bou9@gmail.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>,
linux-doc@vger.kernel.org
Subject: [PATCH 0/2] kconfig: stop implification of choice type
Date: Sat, 27 Apr 2024 19:42:29 +0900 [thread overview]
Message-ID: <20240427104231.2728905-1-masahiroy@kernel.org> (raw)
There are two types supported for the choice statement,
"bool" and "tristate".
There is no ambiguity if you explicitly specifiy the type of the
choice.
For example
choice
bool "choose"
...
endchoice
Or,
choice
tristate "choose"
...
endchoice
Those are valid code, and clear about the behavior.
However, if you see the reality in the kernel code, most of people
omit the type definition.
Usually, the choice is written like this:
choice
prompt "choose"
...
endchoice
The "prompt" does not specify the type at all.
You may wonder how Kconfig knows the choice type then.
When the choice type is not specified, Kconfig infers it from the first
entry within the choice block.
In the following, the choice type is bool because the first entry,
CONFIG_A, is bool.
choice
prompt "choose"
config A
bool "A"
config B
bool "B"
endchoice
As described in 2/2, this has a bug when "if" ... "endif" exists
within a "choice" ... "endchoice".
Of course, I can fix this bug, but the value of this feature is
questionable.
This patch set stop the type implification. Instead, make the
default type of the choice "bool".
This is reasonable because 99% of choice blocks are bool.
The only user of tristate choice is drivers/rapidio/Kconfig.
(although that choice is unneeded because it cotains a single
entry, RAPIDIO_ENUM_BASIC)
It changed it to specify "tristate" explicitly.
Masahiro Yamada (2):
rapidio: specify the type for tristate choice explicitly
kconfig: do not imply the type of choice from the first entry
Documentation/kbuild/kconfig-language.rst | 4 +---
drivers/rapidio/Kconfig | 2 +-
scripts/kconfig/menu.c | 11 -----------
scripts/kconfig/parser.y | 3 +++
scripts/kconfig/tests/choice/Kconfig | 2 +-
scripts/kconfig/tests/choice_value_with_m_dep/Kconfig | 2 +-
6 files changed, 7 insertions(+), 17 deletions(-)
--
2.40.1
next reply other threads:[~2024-04-27 10:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 10:42 Masahiro Yamada [this message]
2024-04-27 10:42 ` [PATCH 1/2] rapidio: specify the type for tristate choice explicitly Masahiro Yamada
2024-05-07 8:30 ` Nicolas Schier
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
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=20240427104231.2728905-1-masahiroy@kernel.org \
--to=masahiroy@kernel.org \
--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=mporter@kernel.crashing.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
/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 NNTP newsgroup(s).