WSL2-Linux-Kernel/scripts
Masahiro Yamada da0fec30a7 kconfig: remove wrong expr_trans_bool()
[ Upstream commit 77a92660d8fe8d29503fae768d9f5eb529c88b36 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-07-27 10:46:09 +02:00
..
atomic
basic
clang-tools gen_compile_commands: fix invalid escape sequence warning 2024-03-26 18:21:12 -04:00
coccinelle
dtc
dummy-tools
gcc-plugins gcc-plugins: Rename last_stmt() for GCC 14+ 2024-07-27 10:46:06 +02:00
gdb scripts/gdb: fix SB_* constants parsing 2024-06-16 13:39:54 +02:00
genksyms
kconfig kconfig: remove wrong expr_trans_bool() 2024-07-27 10:46:09 +02:00
ksymoops
mod modpost: trim leading spaces when processing source files list 2024-02-23 08:55:04 +01:00
package
selinux
tracing
.gitignore
Kbuild.include
Kconfig.include
Lindent
Makefile
Makefile.asm-generic
Makefile.build
Makefile.clang
Makefile.clean
Makefile.compiler powerpc: remove checks for binutils older than 2.25 2024-01-25 14:52:32 -08:00
Makefile.dtbinst kbuild: Install dtb files as 0644 in Makefile.dtbinst 2024-07-05 09:14:48 +02:00
Makefile.extrawarn kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1 2024-04-10 16:18:41 +02:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.host
Makefile.kasan
Makefile.kcov
Makefile.kcsan
Makefile.lib
Makefile.modfinal kbuild: Disable KCSAN for autogenerated *.mod.c intermediaries 2024-05-17 11:50:53 +02:00
Makefile.modinst
Makefile.modpost
Makefile.package
Makefile.ubsan
Makefile.userprogs
adjust_autoksyms.sh
as-version.sh
asn1_compiler.c
bin2c.c
bloat-o-meter
bootgraph.pl
bpf_doc.py bpf, scripts: Correct GPL license name 2024-03-01 13:21:58 +01:00
cc-can-link.sh
cc-version.sh
check-sysctl-docs
check_extable.sh
checkdeclares.pl
checkincludes.pl
checkkconfigsymbols.py
checkpatch.pl
checkstack.pl checkstack: fix printed address 2023-12-13 18:36:43 +01:00
checksyscalls.sh
checkversion.pl
cleanfile
cleanpatch
coccicheck
config
const_structs.checkpatch
decode_stacktrace.sh scripts/decode_stacktrace.sh: optionally use LLVM utilities 2024-02-23 08:55:13 +01:00
decodecode
depmod.sh
dev-needs.sh
diffconfig
documentation-file-ref-check
export_report.pl
extract-cert.c
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
extract_xc3028.pl
faddr2line
file-size.sh
find-unused-docs.sh
gcc-goto.sh
gcc-ld
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen_autoksyms.sh
gen_ksymdeps.sh
generate_initcall_order.pl
get_abi.pl scripts/get_abi: fix source path leak 2024-02-23 08:54:25 +01:00
get_dvb_firmware
get_feat.pl
get_maintainer.pl
gfp-translate
headerdep.pl
headers_check.pl
headers_install.sh
insert-sys-cert.c
jobserver-exec
kallsyms.c
kernel-doc
ld-version.sh kbuild: Make ld-version.sh more robust against version string changes 2024-07-18 13:07:45 +02:00
leaking_addresses.pl
link-vmlinux.sh kbuild: fix short log for AS in link-vmlinux.sh 2024-07-18 13:07:36 +02:00
makelst
markup_oops.pl
min-tool-version.sh
mkcompile_h
mksysmap
mkuboot.sh
module.lds.S
modules-check.sh
nsdeps
objdiff
pahole-flags.sh bpf: Add --skip_encoding_btf_inconsistent_proto, --btf_gen_optimized to pahole flags for v1.25 2024-01-25 14:52:31 -08:00
pahole-version.sh
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c
recordmcount.h
recordmcount.pl
remove-stale-files
setlocalversion
show_delta
sign-file.c sign-file: Fix incorrect return values check 2023-12-20 15:17:37 +01:00
sorttable.c
sorttable.h
spdxcheck-test.sh
spdxcheck.py
spelling.txt
sphinx-pre-install
split-man.pl
stackdelta
stackusage
subarch.include
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh scripts/tags.sh: Resolve gtags empty index generation 2023-07-05 18:25:05 +01:00
tools-support-relr.sh
unifdef.c
ver_linux
xen-hypercalls.sh
xz_wrap.sh