Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Arnout Vandecappelle <arnout@mind.be>
Cc: TIAN Yuanhao <tianyuanhao3@163.com>, buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] package/pkg-utils: prevent KCONFIG_ENABLE_OPT from changing =m to =y
Date: Mon, 25 Jul 2022 17:19:11 +0200	[thread overview]
Message-ID: <20220725151911.GG3168@scaer> (raw)
In-Reply-To: <1dcaf0d5-b00e-b5cb-0c14-f064a90bedb8@mind.be>

Arnout, All,

On 2022-07-25 17:03 +0200, Arnout Vandecappelle spake thusly:
> On 25/07/2022 16:28, Yann E. MORIN wrote:
> >On 2022-07-25 05:09 -0700, TIAN Yuanhao spake thusly:
> >>The KCONFIG_ENABLE_OPT is intended to enable a required kernel configuration
> >>option when a package requires it.
> >>However, this will often override an existing enabled module with `=m` with `=y`
> >>which overrides the module to be built-in instead of separate.
[--SNIP--]
> >This change should not be needed. We now check that the value is already
> >set, and if it is, then we do not touch it. So, if we hit this code, it
> >means we will want to remove any line that has that option.
>  It's still called from KCONFIG_SET_OPT and KCONFIG_DISABLE_OPT without any
> condition.
>  It's true that removing the old line is not strictly needed because the new
> line is appended and thus takes precedence, but you get an ugly warning.

Indeed, my reasoning was that it is not needed to make the =m/=y case
work as expected. Further cleanup can be done in a separate patch with
an appropriate justification.

> >Additionally, since the option is enclosed with \< and \>, then only
> >full-word will match. I.e. if option if DOO, then none of FOO_BAR,
> >BAR_FOO, or BAR_FOO_BUZ would match, so we don't need to optionally
> >match the leading comment symbol.
>  Didn't you yourself give the example of
> CONFIG_FOO="foo"
> CONFIG_BAR="$(CONFIG_FOO)"
> where the original expression would also match the CONFIG_BAR line?
> Arguably, however, that's a separate issue from what gets fixed here.

Gah, I forgot about that case.

Yes, it should be fixed with a separate patch.

Yuanhao, do you want to look into that?

> >>  	echo '$(strip $(2))' >> $(call KCONFIG_DOT_CONFIG,$(3))
> >>  endef
> >>  # KCONFIG_ENABLE_OPT (option [, file])
> >>-KCONFIG_ENABLE_OPT  = $(call KCONFIG_MUNGE_DOT_CONFIG, $(1), $(1)=y, $(2))
> >>+# If the option is already set to =m or =y, ignore.
> >>+define KCONFIG_ENABLE_OPT
> >>+	$(Q)if ! grep -q '^$(strip $(1))=[my]' $(call KCONFIG_DOT_CONFIG,$(2)); then \
> >>+		$(call KCONFIG_MUNGE_DOT_CONFIG, $(1), $(1)=y, $(2)) || exit 1; \
> >
> >The return code of an if statement is the one from the last command in
> >the list. In this case, KCONFIG_MUNGE_DOT_CONFIG expands to a single
> >(compound) command, so if it fails, the if statement will fail, and so
> >the if statement will fail. So, the  "|| exit 1"  here should not be
> >needed.
>  Still, it's defensive programming to have it. Otherwise, if someone later
> adds another line in the condition, they have to remember to add the || exit
> 1.

Yes, I was about to leave it for that reason, but reason 2 below... ;-)

> >Additionally, if we ever change KCONFIG_MUNGE_DOT_CONFIG to be multiple
> >commands, the  "|| exit 1"  would only apply to the last, so that would
> >not catch all failures either.
>  That, on the other hand, is a valid argument.

Yes, and in that cae, it becomes more visible that there is an issue,
and the || exit 1 should be added to each commands that are in
KCONFIG_MUNGE_DOT_CONFIG, not its callers.

Regards,
Yann E. MORIN.

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2022-07-25 15:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17 10:36 [Buildroot] [PATCH v2 1/1] package/pkg-utils: prevent kconfig_enable_opt from changing =m to =y Christian Stewart via buildroot
2022-05-18 18:01 ` Arnout Vandecappelle
2022-05-18 20:21   ` Yann E. MORIN
2022-05-23 11:53     ` TIAN Yuanhao
2022-07-23 22:13       ` Arnout Vandecappelle
2022-07-25 12:09 ` [Buildroot] [PATCH] package/pkg-utils: prevent KCONFIG_ENABLE_OPT " TIAN Yuanhao
2022-07-25 14:28   ` Yann E. MORIN
2022-07-25 15:03     ` Arnout Vandecappelle
2022-07-25 15:19       ` Yann E. MORIN [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=20220725151911.GG3168@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=arnout@mind.be \
    --cc=buildroot@buildroot.org \
    --cc=tianyuanhao3@163.com \
    /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