public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: Dirk Gouders <dirk@gouders.net>
To: Paul Bolle <pebolle@tiscali.nl>
Cc: Martin Walch <walch.martin@web.de>,
	yann.morin.1998@free.fr, Michal Marek <mmarek@suse.cz>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] kconfig: fix bad syntactic transformation in expr.c
Date: Tue, 07 Oct 2014 11:21:51 +0200	[thread overview]
Message-ID: <ghzjd8tets.fsf@lena.gouders.net> (raw)
In-Reply-To: <1412669443.18874.16.camel@x220> (Paul Bolle's message of "Tue, 07 Oct 2014 10:10:43 +0200")

CC: Michal added

Paul Bolle <pebolle@tiscali.nl> writes:

> On Mon, 2014-09-22 at 19:13 +0200, Martin Walch wrote:
>> expr_eliminate_dups2() in scripts/kconfig/expr.c applies two bad
>> inference rules:
>> 
>> (FOO || BAR) && (!FOO && !BAR) -> n
>> (FOO && BAR) || (!FOO || !BAR) -> y
>> 
>> They would be correct in propositional logic, but this is a three-valued
>> logic, and here it is wrong in that it changes semantics. It becomes
>> immediately visible when substituting FOO and BAR with m.
>
> Well, not to me. When I apply the rules under "Menu dependencies" in
> Documentation/kbuild/kconfig-language.txt, in embarrassingly small
> steps, I get:
>     (m || m) && (!m && !m) ->
>     (1 || 1) && ((2 - 1) && (2 - 1)) ->
>     (1 || 1) && (1 && 1) ->
>     max(1, 1) && min(1, 1) ->
>     1 && 1 ->
>     min(1, 1) ->
>     1 -> m
>
> and
>     (m && m) || (!m || !m) ->
>     (1 && 1) || ((2 - 1) || (2 - 1)) ->
>     (1 && 1) || (1 || 1) ->
>     min(1, 1) || max(1, 1) ->
>     1 || 1 ->
>     max(1, 1) ->
>     1 -> m
>
> Did I do that right? Anyway, perhaps you'd like to add a line or two how
> these two expressions actually evaluate when FOO and BAR are m.

Perhaps, it helps to use a Kconfig file that visualizes the problem:

mainmenu "Expr Test"

config expr-config
	bool "Expr Config"
	depends on (m || m) && (!m && !m)
#	depends on (m && m) || (!m || !m)

config dummy
       bool "Dummy"

config modules
       bool
       option modules
       default y

Those two depends, according to your calculation and if I understood
correctly also to Martin's, should evaluate to 'm' and thus the menu
entry should always be visible, because both depends should evaluate to
'm'.  But because of expr_eliminate_dups2() it is either invisible (the
first depends becomes 'n') or always visible (the second depends becomes
'y').

Dirk

>> Fix it by removing expr_eliminate_dups2() and the functions that have no use
>> anywhere else: expr_extract_eq_and(), expr_extract_eq_or(),
>> and expr_extract_eq() from scripts/kconfig/expr.[ch]
>> 
>> Currently the bug is not triggered in mainline, so this patch does not modify
>> the configuration space there.
>> 
>> As a side effect, this reduces code size in expr.c by roughly 10% and slightly
>> improves startup time for all configuration frontends.
>> 
>> Signed-off-by: Martin Walch <walch.martin@web.de>
>
> Does Yann still care about Kconfig? Yann has been rather quiet for a
> while now.
>
>
> Paul Bolle
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2014-10-07  9:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 14:31 [RESEND PATCH v2 0/2] kconfig: Remove bad inference rules expr_eliminate_dups2() Martin Walch
2014-09-22 17:13 ` [Resending PATCH v2 0/2] kconfig: fix bad syntactic transformation Martin Walch
2014-09-22 17:13   ` [PATCH v2 1/2] kconfig: fix bad syntactic transformation in expr.c Martin Walch
2014-10-07  8:10     ` Paul Bolle
2014-10-07  9:21       ` Dirk Gouders [this message]
2014-10-11  0:20         ` Martin Walch
2014-10-11 19:07     ` Paul Bolle
2014-09-22 17:13   ` [PATCH v2 2/2] kconfig: trivial - adjust comments Martin Walch
2014-10-10 13:01     ` Paul Bolle

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=ghzjd8tets.fsf@lena.gouders.net \
    --to=dirk@gouders.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=pebolle@tiscali.nl \
    --cc=walch.martin@web.de \
    --cc=yann.morin.1998@free.fr \
    /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