linux-stable/scripts/kconfig
Martin Walch e911503085 Kconfig: Remove bad inference rules expr_eliminate_dups2()
expr_eliminate_dups2() in scripts/kconfig/expr.c applies two invalid
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 assigning the value 1 to both, FOO and BAR:

(FOO || BAR) && (!FOO && !BAR)
-> min(max(1, 1), min(2-1, 2-1)) = min(1, 1) = 1

while n evaluates to 0 and

(FOO && BAR) || (!FOO || !BAR)
-> max(min(1, 1), max(2-1, 2-1)) = max(1, 1) = 1

with y evaluating to 2.

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.c

Currently the bug is not triggered in mainline, so this patch does not
modify the configuration space there. To observe the bug consider this
example:

config MODULES
        def_bool y
        option modules

config FOO
        def_tristate m

config BAR
        def_tristate m

config TEST1
        def_tristate y
        depends on (FOO || BAR) && (!FOO && !BAR)

if TEST1 = n
comment "TEST1 broken"
endif

config TEST2
        def_tristate y
        depends on (FOO && BAR) || (!FOO || !BAR)

if TEST2 = y
comment "TEST2 broken"
endif

config TEST3
        def_tristate y
        depends on m && !m

if TEST3 = n
comment "TEST3 broken"
endif

TEST1, TEST2 and TEST3 should all evaluate to m, but without the patch,
none of them does. It is probably not obvious that TEST3 is the same bug,
but it becomes clear when considering what happens internally to the
expression
m && !m":
First it expands to
(m && MODULES) && !(m && MODULES),
then it is transformed into
(m && MODULES) && (!m || !MODULES),
and finally due to the bug it is replaced with n.

As a side effect, this patch 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>
Signed-off-by: Michal Marek <mmarek@suse.cz>
2015-05-25 16:04:12 +08:00
..
lxdialog kconfig/lxdialog: get ncurses CFLAGS with pkg-config 2014-09-23 15:47:48 +02:00
.gitignore kconfig: remove lkc_defs.h from .gitignore and dontdiff 2012-07-13 15:08:25 +02:00
check.sh kbuild: trivial - remove trailing empty lines 2014-06-10 00:04:06 +02:00
conf.c kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
confdata.c kconfig: Remove unnecessary prototypes from headers 2015-02-25 15:00:17 +01:00
expr.c Kconfig: Remove bad inference rules expr_eliminate_dups2() 2015-05-25 16:04:12 +08:00
expr.h kconfig: Remove unnecessary prototypes from headers 2015-02-25 15:00:17 +01:00
gconf.c kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
gconf.glade scripts/kconfig/gconf.glade Update broken web addresses. 2010-09-17 16:54:42 +02:00
images.c
kxgettext.c kconfig: nuke LKC_DIRECT_LINK cruft 2011-06-06 15:32:20 -04:00
list.h Replace mentions of "list_struct" to "list_head" 2014-11-20 14:45:15 +01:00
lkc.h kconfig: Remove unnecessary prototypes from headers 2015-02-25 15:00:17 +01:00
lkc_proto.h kconfig: Remove unnecessary prototypes from headers 2015-02-25 15:00:17 +01:00
Makefile kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
mconf.c kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
menu.c kconfig: Remove unnecessary prototypes from headers 2015-02-25 15:00:17 +01:00
merge_config.sh merge_config.sh: rename MAKE to RUNMAKE 2015-03-24 16:48:44 +01:00
nconf.c kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
nconf.gui.c nconf: use function calls instead of ncurses' variables LINES and COLS 2013-06-18 23:58:58 +02:00
nconf.h scripts/kconfig/nconf: dynamically alloc dialog_input_result 2011-09-09 14:40:08 +02:00
POTFILES.in
qconf.cc kconfig: Do not print status messages in make -s mode 2015-04-09 17:44:34 +02:00
qconf.h xconfig: Fix the filename for GUI settings 2013-10-08 23:52:16 +02:00
streamline_config.pl kbuild: Make scripts executable 2014-08-20 16:03:45 +02:00
symbol.c kconfig: Remove unnecessary prototypes from headers 2015-02-25 15:00:17 +01:00
util.c kconfig: Remove dead code 2015-02-25 15:00:16 +01:00
zconf.gperf kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT 2014-04-07 16:36:09 -07:00
zconf.hash.c_shipped kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT 2014-04-07 16:36:09 -07:00
zconf.l kbuild: trivial - use tabs for code indent where possible 2014-06-10 14:00:53 +02:00
zconf.lex.c_shipped kbuild: trivial - use tabs for code indent where possible 2014-06-10 14:00:53 +02:00
zconf.tab.c_shipped kbuild: trivial - use tabs for code indent where possible 2014-06-10 14:00:53 +02:00
zconf.y kbuild: trivial - use tabs for code indent where possible 2014-06-10 14:00:53 +02:00