linux/scripts/kconfig
Masahiro Yamada 77a92660d8 kconfig: remove wrong expr_trans_bool()
expr_trans_bool() performs an incorrect transformation.

[Test Code]

    config MODULES
            def_bool y
            modules

    config A
            def_bool y
            select C if B != n

    config B
            def_tristate m

    config C
            tristate

[Result]

    CONFIG_MODULES=y
    CONFIG_A=y
    CONFIG_B=m
    CONFIG_C=m

This output is incorrect because CONFIG_C=y is expected.

Documentation/kbuild/kconfig-language.rst clearly explains the function
of the '!=' operator:

    If the values of both symbols are equal, it returns 'n',
    otherwise 'y'.

Therefore, the statement:

    select C if B != n

should be equivalent to:

    select C if y

Or, more simply:

    select C

Hence, the symbol C should be selected by the value of A, which is 'y'.

However, expr_trans_bool() wrongly transforms it to:

    select C if B

Therefore, the symbol C is selected by (A && B), which is 'm'.

The comment block of expr_trans_bool() correctly explains its intention:

  * bool FOO!=n => FOO
    ^^^^

If FOO is bool, FOO!=n can be simplified into FOO. This is correct.

However, the actual code performs this transformation when FOO is
tristate:

    if (e->left.sym->type == S_TRISTATE) {
                             ^^^^^^^^^^

While it can be fixed to S_BOOLEAN, there is no point in doing so
because expr_tranform() already transforms FOO!=n to FOO when FOO is
bool. (see the "case E_UNEQUAL" part)

expr_trans_bool() is wrong and unnecessary.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
2024-06-06 20:09:10 +09:00
..
lxdialog kconfig: lxdialog: remove initialization with A_NORMAL 2024-05-14 23:36:19 +09:00
tests kconfig: remove 'optional' property support 2024-05-02 19:48:26 +09:00
.gitignore kconfig: Update all declared targets 2023-01-13 16:29:52 +09:00
array_size.h kconfig: move ARRAY_SIZE to a header 2024-02-19 18:20:41 +09:00
conf.c kconfig: turn conf_choice() into void function 2024-05-10 04:34:53 +09:00
confdata.c kconfig: remove unneeded code for user-supplied values being out of range 2024-06-06 20:03:14 +09:00
expr.c kconfig: remove wrong expr_trans_bool() 2024-06-06 20:09:10 +09:00
expr.h kconfig: remove wrong expr_trans_bool() 2024-06-06 20:09:10 +09:00
gconf-cfg.sh kconfig: refactor Makefile to reduce process forks 2022-12-13 22:29:10 +09:00
gconf.c kconfig: gconf: give a proper initial state to the Save button 2024-06-06 20:03:16 +09:00
gconf.glade scripts/kconfig/gconf.glade Update broken web addresses. 2010-09-17 16:54:42 +02:00
hashtable.h kconfig: add macros useful for hashtable 2024-02-19 18:20:41 +09:00
images.c kconfig: constify XPM data 2020-08-14 13:30:03 +09:00
images.h kconfig: constify XPM data 2020-08-14 13:30:03 +09:00
internal.h kconfig: use generic macros to implement symbol hashtable 2024-02-20 20:47:45 +09:00
lexer.l kconfig: remove 'optional' property support 2024-05-02 19:48:26 +09:00
list.h kconfig: import more list macros and inline functions 2024-02-19 18:20:41 +09:00
list_types.h kconfig: import more list macros and inline functions 2024-02-19 18:20:41 +09:00
lkc.h kconfig: remove 'optional' property support 2024-05-02 19:48:26 +09:00
lkc_proto.h kconfig: add sym_get_choice_menu() helper 2024-05-10 04:34:53 +09:00
Makefile kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
mconf-cfg.sh kconfig: refactor Makefile to reduce process forks 2022-12-13 22:29:10 +09:00
mconf.c kconfig: m/nconf: merge two item_add_str() calls 2024-05-14 23:36:19 +09:00
menu.c kconfig: remove wrong expr_trans_bool() 2024-06-06 20:09:10 +09:00
merge_config.sh scripts: merge_config: Fix typo in variable name. 2023-03-23 15:27:40 +09:00
mnconf-common.c kconfig: factor out common code shared by mconf and nconf 2023-12-10 15:34:37 +09:00
mnconf-common.h kconfig: factor out common code shared by mconf and nconf 2023-12-10 15:34:37 +09:00
nconf-cfg.sh kconfig: refactor Makefile to reduce process forks 2022-12-13 22:29:10 +09:00
nconf.c kconfig: m/nconf: merge two item_add_str() calls 2024-05-14 23:36:19 +09:00
nconf.gui.c kconfig: nconf: Add search jump feature 2023-08-13 21:29:41 +09:00
nconf.h kconfig: nconf: Add search jump feature 2023-08-13 21:29:41 +09:00
parser.y kconfig: turn defaults and additional prompt for choice members into error 2024-05-10 04:34:53 +09:00
preprocess.c kconfig: move ARRAY_SIZE to a header 2024-02-19 18:20:41 +09:00
preprocess.h kconfig: split preprocessor prototypes into preprocess.h 2024-02-19 18:20:40 +09:00
qconf-cfg.sh kconfig: port qconf to work with Qt6 in addition to Qt5 2023-08-16 12:06:29 +09:00
qconf.cc kconfig: associate struct menu with file name directly 2024-02-19 18:20:40 +09:00
qconf.h kconfig: qconf: remove Y, M, N columns 2020-09-25 00:37:13 +09:00
streamline_config.pl streamline_config.pl: handle also ${CONFIG_FOO} 2023-06-08 11:11:32 +09:00
symbol.c kconfig: fix comparison to constant symbols, 'm', 'n' 2024-05-29 16:40:03 +09:00
util.c kconfig: convert linked list of files to hash table 2024-02-20 20:44:48 +09:00