History log of /linux-master/scripts/kconfig/confdata.c
Revision Date Author Comments
# b27a9138 10-Mar-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove unneeded menu_is_visible() call in conf_write_defconfig()

When the condition 'sym == NULL' is met, the code will reach the
'next_menu' label regardless of the return value from menu_is_visible().

menu_is_visible() calculates some symbol values as a side-effect, for
instance by calling expr_calc_value(menu->visibility), but all the
symbol values will be calculated eventually.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 91b69454 11-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: use generic macros to implement symbol hashtable

Use helper macros in hashtable.h for generic hashtable implementation.

We can git rid of the hash head index of for_all_symbols().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 56e634b0 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: call env_write_dep() right after yyparse()

This allows preprocess.c to free up all of its resources when the parse
stage is finished. It also ensures conf_write_autoconf_cmd() produces
consistent results even if called multiple times for any reason.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 526396b7 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: write Kconfig files to autoconf.cmd in order

Currently, include/config/autoconf.cmd saves included Kconfig files in
reverse order. While this is not a big deal, it is inconsistent with
other *.cmd files generated by fixdep.

Output the included Kconfig files in the included order.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# aa8427fb 02-Feb-2024 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove compat_getline()

Commit 1a7a8c6fd8ca ("kconfig: allow long lines in config file") added
a self-implemented getline() for better portability.

However, getline() is standardized [1] and already used in other programs
such as scripts/kallsyms.c.

Use getline() provided by libc.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 15d3f766 21-Nov-2023 Sergey Senozhatsky <senozhatsky@chromium.org>

kconfig: WERROR unmet symbol dependency

When KCONFIG_WERROR env variable is set treat unmet direct
symbol dependency as a terminal condition (error).

Suggested-by: Stefan Reinauer <reinauer@google.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 407868de 03-Dec-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove redundant NULL pointer check before free()

Passing NULL to free() is allowed and is a no-op.

Remove redundant NULL pointer checks.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 48ab6c9c 18-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: massage the loop in conf_read_simple()

Make the while-loop code a little more readable.

The gain is that "CONFIG_FOO" without '=' is warned as unexpected data.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 4aced3ec 18-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: require an exact match for "is not set" to disable CONFIG option

Currently, any string starting "is not set" disables a CONFIG option.

For example, "# CONFIG_FOO is not settled down" is accepted as valid
input, functioning the same as "# CONFIG_FOO is not set". It is a
long-standing oddity.

Check the line against the exact pattern "is not set".

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 9925d6b7 18-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: introduce getline_stripped() helper

Currently, newline characters are stripped away in multiple places
on the caller.

Doing that in the callee is helpful for further cleanups.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# d854b4b2 18-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: deduplicate code in conf_read_simple()

Kconfig accepts both "# CONFIG_FOO is not set" and "CONFIG_FOO=n" as
a valid input, but conf_read_simple() duplicates similar code to handle
them. Factor out the common code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 92d4fe0a 18-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove unused code for S_DEF_AUTO in conf_read_simple()

The 'else' arm here is unreachable in practical use cases.

include/config/auto.conf does not include "# CONFIG_... is not set"
line unless it is manually hacked.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 4d137ab0 18-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: require a space after '#' for valid input

Currently, when an input line starts with '#', (line + 2) is passed to
memcmp() without checking line[1].

It means that line[1] can be any arbitrary character. For example,
"#KCONFIG_FOO is not set" is accepted as valid input, functioning the
same as "# CONFIG_FOO is not set".

More importantly, this can potentially lead to a buffer overrun if
line[1] == '\0'. It occurs if the input only contains '#', as
(line + 2) points to an uninitialized buffer.

Check line[1], and skip the line if it is not a space.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 61e3e3c2 17-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove error check for xrealloc()

xrealloc() never returns NULL as it is checked in the callee.

This is a left-over of commit d717f24d8c68 ("kconfig: add xrealloc()
helper").

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# ce1fc934 05-Nov-2023 Masahiro Yamada <masahiroy@kernel.org>

kconfig: do not clear SYMBOL_DEF_USER when the value is out of range

When a user-supplied value is out of range, (NEW) and an incorrect default
value are shown.

[Test Kconfig]

config FOO
int "foo"
range 10 20

[Test .config]

CONFIG_FOO=30

[Result without this fix]

$ make config
*
* Main menu
*
foo (FOO) [10] (NEW)

[Result with this fix]

$ make config
*
* Main menu
*
foo (FOO) [20]

Currently, the SYMBOL_DEF_USER is cleared if the user input does not
reside within the range. Kconfig forgets the initial value 30, and
prints (NEW) and an incorrect default [10].

Kconfig should remember the user's input. The default should be [20]
because the user's input, 30, is closer to the upper limit of the range.

Please note it will not show up in "make oldconfig" because it is no
longer considered as a new symbol. It also fixes the inconsistent
behavior in listnewconfig/helpnewconfig.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 7cd34300 29-Aug-2023 Sergey Senozhatsky <senozhatsky@chromium.org>

kconfig: add warn-unknown-symbols sanity check

Introduce KCONFIG_WARN_UNKNOWN_SYMBOLS environment variable,
which makes Kconfig warn about unknown config symbols.

This is especially useful for continuous kernel uprevs when
some symbols can be either removed or renamed between kernel
releases (which can go unnoticed otherwise).

By default KCONFIG_WARN_UNKNOWN_SYMBOLS generates warnings,
which are non-terminal. There is an additional environment
variable KCONFIG_WERROR that overrides this behaviour and
turns warnings into errors.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# ee06a3ef 07-Mar-2023 Jurica Vukadin <jura@vukad.in>

kconfig: Update config changed flag before calling callback

Prior to commit 5ee546594025 ("kconfig: change sym_change_count to a
boolean flag"), the conf_updated flag was set to the new value *before*
calling the callback. xconfig's save action depends on this behaviour,
because xconfig calls conf_get_changed() directly from the callback and
now sees the old value, thus never enabling the save button or the
shortcut.

Restore the previous behaviour.

Fixes: 5ee546594025 ("kconfig: change sym_change_count to a boolean flag")
Signed-off-by: Jurica Vukadin <jura@vukad.in>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 2f7ab126 03-Jul-2021 Miguel Ojeda <ojeda@kernel.org>

Kbuild: add Rust support

Having most of the new files in place, we now enable Rust support
in the build system, including `Kconfig` entries related to Rust,
the Rust configuration printer and a few other bits.

Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Co-developed-by: Alex Gaynor <alex.gaynor@gmail.com>
Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
Co-developed-by: Finn Behrens <me@kloenk.de>
Signed-off-by: Finn Behrens <me@kloenk.de>
Co-developed-by: Adam Bratschi-Kaye <ark.email@gmail.com>
Signed-off-by: Adam Bratschi-Kaye <ark.email@gmail.com>
Co-developed-by: Wedson Almeida Filho <wedsonaf@google.com>
Signed-off-by: Wedson Almeida Filho <wedsonaf@google.com>
Co-developed-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Co-developed-by: Sven Van Asbroeck <thesven73@gmail.com>
Signed-off-by: Sven Van Asbroeck <thesven73@gmail.com>
Co-developed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Gary Guo <gary@garyguo.net>
Co-developed-by: Boris-Chengbiao Zhou <bobo1239@web.de>
Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de>
Co-developed-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Co-developed-by: Douglas Su <d0u9.su@outlook.com>
Signed-off-by: Douglas Su <d0u9.su@outlook.com>
Co-developed-by: Dariusz Sosnowski <dsosnowski@dsosnowski.pl>
Signed-off-by: Dariusz Sosnowski <dsosnowski@dsosnowski.pl>
Co-developed-by: Antonio Terceiro <antonio.terceiro@linaro.org>
Signed-off-by: Antonio Terceiro <antonio.terceiro@linaro.org>
Co-developed-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Co-developed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Signed-off-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Co-developed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Signed-off-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>


# b6ad5416 28-Mar-2022 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove stale comment about removed kconfig_print_symbol()

This comment is about kconfig_print_symbol(), which was removed by
commit 6ce45a91a982 ("kconfig: refactor conf_write_symbol()").

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# a7d4f58e 13-Feb-2022 Masahiro Yamada <masahiroy@kernel.org>

kconfig: fix missing '# end of' for empty menu

Currently, "# end of ..." is inserted when the menu goes back to its
parent.

Hence, an empty menu:

menu "Foo"
endmenu

... ends up with unbalanced menu comments, like this:

#
# Foo
#

Let's close the menu comments properly:

#
# Foo
#
# end of Foo

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 868653f4 12-Feb-2022 Masahiro Yamada <masahiroy@kernel.org>

kconfig: add fflush() before ferror() check

As David Laight pointed out, there is not much point in calling
ferror() unless you call fflush() first.

Reported-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 1b9e740a 11-Feb-2022 Jing Leng <jleng@ambarella.com>

kconfig: fix failing to generate auto.conf

When the KCONFIG_AUTOCONFIG is specified (e.g. export \
KCONFIG_AUTOCONFIG=output/config/auto.conf), the directory of
include/config/ will not be created, so kconfig can't create deps
files in it and auto.conf can't be generated.

Signed-off-by: Jing Leng <jleng@ambarella.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# d23a0c37 07-Feb-2022 Masahiro Yamada <masahiroy@kernel.org>

kconfig: fix missing fclose() on error paths

The file is not closed when ferror() fails.

Fixes: 00d674cb3536 ("kconfig: refactor conf_write_dep()")
Fixes: 57ddd07c4560 ("kconfig: refactor conf_write_autoconf()")
Reported-by: Ryan Cai <ycaibb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 129ab0d2 13-Dec-2021 Masahiro Yamada <masahiroy@kernel.org>

kbuild: do not quote string values in include/config/auto.conf

The previous commit fixed up all shell scripts to not include
include/config/auto.conf.

Now that include/config/auto.conf is only included by Makefiles,
we can change it into a more Make-friendly form.

Previously, Kconfig output string values enclosed with double-quotes
(both in the .config and include/config/auto.conf):

CONFIG_X="foo bar"

Unlike shell, Make handles double-quotes (and single-quotes as well)
verbatim. We must rip them off when used.

There are some patterns:

[1] $(patsubst "%",%,$(CONFIG_X))
[2] $(CONFIG_X:"%"=%)
[3] $(subst ",,$(CONFIG_X))
[4] $(shell echo $(CONFIG_X))

These are not only ugly, but also fragile.

[1] and [2] do not work if the value contains spaces, like
CONFIG_X=" foo bar "

[3] does not work correctly if the value contains double-quotes like
CONFIG_X="foo\"bar"

[4] seems to work better, but has a cost of forking a process.

Anyway, quoted strings were always PITA for our Makefiles.

This commit changes Kconfig to stop quoting in include/config/auto.conf.

These are the string type symbols referenced in Makefiles or scripts:

ACPI_CUSTOM_DSDT_FILE
ARC_BUILTIN_DTB_NAME
ARC_TUNE_MCPU
BUILTIN_DTB_SOURCE
CC_IMPLICIT_FALLTHROUGH
CC_VERSION_TEXT
CFG80211_EXTRA_REGDB_KEYDIR
EXTRA_FIRMWARE
EXTRA_FIRMWARE_DIR
EXTRA_TARGETS
H8300_BUILTIN_DTB
INITRAMFS_SOURCE
LOCALVERSION
MODULE_SIG_HASH
MODULE_SIG_KEY
NDS32_BUILTIN_DTB
NIOS2_DTB_SOURCE
OPENRISC_BUILTIN_DTB
SOC_CANAAN_K210_DTB_SOURCE
SYSTEM_BLACKLIST_HASH_LIST
SYSTEM_REVOCATION_KEYS
SYSTEM_TRUSTED_KEYS
TARGET_CPU
UNUSED_KSYMS_WHITELIST
XILINX_MICROBLAZE0_FAMILY
XILINX_MICROBLAZE0_HW_VER
XTENSA_VARIANT_NAME

I checked them one by one, and fixed up the code where necessary.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# fee762d6 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: refactor conf_touch_dep()

If this function fails to touch a dummy header due to missing parent
directory, then it creates it and touches the file again.

This was needed because CONFIG_FOO_BAR was previously tracked by
include/config/foo/bar.h. (include/config/foo/ may not exist here)

This is no longer the case since commit 0e0345b77ac4 ("kbuild: redo
fake deps at include/config/*.h"); now all the fake headers are placed
right under include/config/, like include/config/FOO_BAR.

Do not try to create parent directory, include/config/, which already
exists.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 00d674cb 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: refactor conf_write_dep()

The if ... else inside the for-loop is unneeded because one empty
line is placed after printing the last element of deps_config.

Currently, all errors in conf_write_dep() are ignored. Add proper
error checks.

Rename it to conf_write_autoconf_cmd(), which is more intuitive.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 57ddd07c 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: refactor conf_write_autoconf()

This function does similar for auto.conf and autoconf.h

Create __conf_write_autoconf() helper to factor out the common code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 8499f2dd 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: add conf_get_autoheader_name()

For consistency with conf_get_autoconfig_name()

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 80f7bc77 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: move sym_escape_string_value() to confdata.c

Now that sym_escape_string_value() is only used in confdata.c
it can be a 'static' function.

Rename it escape_string_value() because it is agnostic about
(struct sym *).

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 51d792cb 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: refactor listnewconfig code

We can reuse __print_symbol() helper to print symbols for listnewconfig.
Only the difference is the format for "n" symbols.

This prints "CONFIG_FOO=n" instead of "# CONFIG_FOO is not set".

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 6ce45a91 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: refactor conf_write_symbol()

I do not think 'struct conf_printer' is so useful.

Add simple functions, print_symbol_for_*() to write out one symbol.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# ca51b26b 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: refactor conf_write_heading()

All the call sites of conf_write_heading() pass NULL to the third
argument, and it is not used in the function.

Also, the print_comment hooks are doing much more complex than
needed.

Rewrite the code.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 229d0cfa 30-Sep-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: remove 'const' from the return type of sym_escape_string_value()

sym_escape_string_value() returns a malloc'ed memory, but as
(const char *). So, it must be casted to (void *) when it is free'd.
This is odd.

The return type of sym_escape_string_value() should be (char *).

I exploited that free(NULL) has no effect.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 0e0345b7 15-Apr-2021 Alexey Dobriyan <adobriyan@gmail.com>

kbuild: redo fake deps at include/config/*.h

Make include/config/foo/bar.h fake deps files generation simpler.

* delete .h suffix
those aren't header files, shorten filenames,

* delete tolower()
Linux filesystems can deal with both upper and lowercase
filenames very well,

* put everything in 1 directory
Presumably 'mkdir -p' split is from dark times when filesystems
handled huge directories badly, disks were round adding to
seek times.

x86_64 allmodconfig lists 12364 files in include/config.

../obj/include/config/
├── 104_QUAD_8
├── 60XX_WDT
├── 64BIT
...
├── ZSWAP_DEFAULT_ON
├── ZSWAP_ZPOOL_DEFAULT
└── ZSWAP_ZPOOL_DEFAULT_ZBUD

0 directories, 12364 files

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 5ee54659 10-Apr-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change sym_change_count to a boolean flag

sym_change_count has no good reason to be 'int' type.

sym_set_change_count() compares the old and new values after casting
both of them to (bool). I do not see any practical diffrence between
sym_set_change_count(1) and sym_add_change_count(1).

Use the boolean flag, conf_changed.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# a69b191f 15-Mar-2021 Yang Li <yang.lee@linux.alibaba.com>

kconfig: use true and false for bool variable

fixed the following coccicheck:
./scripts/kconfig/confdata.c:36:9-10: WARNING: return of 0/1 in function
'is_dir' with return type bool

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# b75b0a81 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: change defconfig_list option to environment variable

"defconfig_list" is a weird option that defines a static symbol that
declares the list of base config files in case the .config does not
exist yet.

This is quite different from other normal symbols; we just abused the
"string" type and the "default" properties to list out the input files.
They must be fixed values since these are searched for and loaded in
the parse stage.

It is an ugly hack, and should not exist in the first place. Providing
this feature as an environment variable is a saner approach.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 98f8475c 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: move conf_set_all_new_symbols() to conf.c

This function is only used in conf.c. Move it there together with the
randomize_choice_values() helper.

Define 'enum conf_def_mode' locally in conf.c as well.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 15e68d09 13-Mar-2021 Masahiro Yamada <masahiroy@kernel.org>

kconfig: move conf_rewrite_mod_or_yes() to conf.c

This function is only used in conf.c.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 78cb0907 23-Nov-2020 Boris Kolpackov <boris@codesynthesis.com>

kconfig: clean up header inclusion

- Add missing includes.
- Remove no longer necessary includes.

Signed-off-by: Boris Kolpackov <boris@codesynthesis.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 089b7d89 03-Feb-2020 Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>

kconfig: Invalidate all symbols after changing to y or m.

Since commit 89b9060987d9 ("kconfig: Add yes2modconfig and
mod2yesconfig targets.") forgot to clear SYMBOL_VALID bit after
changing to y or m, these targets did not save the changes.
Call sym_clear_all_valid() so that all symbols are revalidated.

Fixes: 89b9060987d9 ("kconfig: Add yes2modconfig and mod2yesconfig targets.")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# c8fb7d7e 31-Jan-2020 Masahiro Yamada <masahiroy@kernel.org>

kconfig: fix broken dependency in randconfig-generated .config

Running randconfig on arm64 using KCONFIG_SEED=0x40C5E904 (e.g. on v5.5)
produces the .config with CONFIG_EFI=y and CONFIG_CPU_BIG_ENDIAN=y,
which does not meet the !CONFIG_CPU_BIG_ENDIAN dependency.

This is because the user choice for CONFIG_CPU_LITTLE_ENDIAN vs
CONFIG_CPU_BIG_ENDIAN is set by randomize_choice_values() after the
value of CONFIG_EFI is calculated.

When this happens, the has_changed flag should be set.

Currently, it takes the result from the last iteration. It should
accumulate all the results of the loop.

Fixes: 3b9a19e08960 ("kconfig: loop as long as we changed some symbols in randconfig")
Reported-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 89b90609 17-Dec-2019 Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>

kconfig: Add yes2modconfig and mod2yesconfig targets.

Since kernel configs provided by syzbot are close to "make allyesconfig",
it takes long time to rebuild. This is especially waste of time when we
need to rebuild for many times (e.g. doing manual printk() inspection,
bisect operations).

We can save time if we can exclude modules which are irrelevant to each
problem. But "make localmodconfig" cannot exclude modules which are built
into vmlinux because /sbin/lsmod output is used as the source of modules.

Therefore, this patch adds "make yes2modconfig" which converts from =y
to =m if possible. After confirming that the interested problem is still
reproducible, we can try "make localmodconfig" (and/or manually tune
based on "Modules linked in:" line) in order to exclude modules which are
irrelevant to the interested problem. While we are at it, this patch also
adds "make mod2yesconfig" which converts from =m to =y in case someone
wants to convert from =m to =y after "make localmodconfig".

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 8b41fc44 19-Dec-2019 Masahiro Yamada <masahiroy@kernel.org>

kbuild: create modules.builtin without Makefile.modbuiltin or tristate.conf

Commit bc081dd6e9f6 ("kbuild: generate modules.builtin") added
infrastructure to generate modules.builtin, the list of all
builtin modules.

Basically, it works like this:

- Kconfig generates include/config/tristate.conf, the list of
tristate CONFIG options with a value in a capital letter.

- scripts/Makefile.modbuiltin makes Kbuild descend into
directories to collect the information of builtin modules.

I am not a big fan of it because Kbuild ends up with traversing
the source tree twice.

I am not sure how perfectly it should work, but this approach cannot
avoid false positives; even if the relevant CONFIG option is tristate,
some Makefiles forces obj-m to obj-y.

Some examples are:

arch/powerpc/platforms/powermac/Makefile:
obj-$(CONFIG_NVRAM:m=y) += nvram.o

net/ipv6/Makefile:
obj-$(subst m,y,$(CONFIG_IPV6)) += inet6_hashtables.o

net/netlabel/Makefile:
obj-$(subst m,y,$(CONFIG_IPV6)) += netlabel_calipso.o

Nobody has complained about (or noticed) it, so it is probably fine to
have false positives in modules.builtin.

This commit simplifies the implementation. Let's exploit the fact
that every module has MODULE_LICENSE(). (modpost shows a warning if
MODULE_LICENSE is missing. If so, 0-day bot would already have blocked
such a module.)

I added MODULE_FILE to <linux/module.h>. When the code is being compiled
as builtin, it will be filled with the file path of the module, and
collected into modules.builtin.info. Then, scripts/link-vmlinux.sh
extracts the list of builtin modules out of it.

This new approach fixes the false-positives above, but adds another
type of false-positives; non-modular code may have MODULE_LICENSE()
by mistake. This is not a big deal, it is just the code is always
orphan. We can clean it up if we like. You can see cleanup examples by:

$ git log --grep='make.* explicitly non-modular'

To sum up, this commits deletes lots of code, but still produces almost
equivalent results. Please note it does not increase the vmlinux size at
all. As you can see in include/asm-generic/vmlinux.lds.h, the .modinfo
section is discarded in the link stage.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>


# 0c5b6c28 03-Aug-2019 M. Vefa Bicakci <m.v.b@runbox.com>

kconfig: Clear "written" flag to avoid data loss

Prior to this commit, starting nconfig, xconfig or gconfig, and saving
the .config file more than once caused data loss, where a .config file
that contained only comments would be written to disk starting from the
second save operation.

This bug manifests itself because the SYMBOL_WRITTEN flag is never
cleared after the first call to conf_write, and subsequent calls to
conf_write then skip all of the configuration symbols due to the
SYMBOL_WRITTEN flag being set.

This commit resolves this issue by clearing the SYMBOL_WRITTEN flag
from all symbols before conf_write returns.

Fixes: 8e2442a5f86e ("kconfig: fix missing choice values in auto.conf")
Cc: linux-stable <stable@vger.kernel.org> # 4.19+
Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 8e2442a5 12-Jul-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: fix missing choice values in auto.conf

Since commit 00c864f8903d ("kconfig: allow all config targets to write
auto.conf if missing"), Kconfig creates include/config/auto.conf in the
defconfig stage when it is missing.

Joonas Kylmälä reported incorrect auto.conf generation under some
circumstances.

To reproduce it, apply the following diff:

| --- a/arch/arm/configs/imx_v6_v7_defconfig
| +++ b/arch/arm/configs/imx_v6_v7_defconfig
| @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y
| CONFIG_USB_CONFIGFS_F_HID=y
| CONFIG_USB_CONFIGFS_F_UVC=y
| CONFIG_USB_CONFIGFS_F_PRINTER=y
| -CONFIG_USB_ZERO=m
| -CONFIG_USB_AUDIO=m
| -CONFIG_USB_ETH=m
| -CONFIG_USB_G_NCM=m
| -CONFIG_USB_GADGETFS=m
| -CONFIG_USB_FUNCTIONFS=m
| -CONFIG_USB_MASS_STORAGE=m
| -CONFIG_USB_G_SERIAL=m
| +CONFIG_USB_FUNCTIONFS=y
| CONFIG_MMC=y
| CONFIG_MMC_SDHCI=y
| CONFIG_MMC_SDHCI_PLTFM=y

And then, run:

$ make ARCH=arm mrproper imx_v6_v7_defconfig

You will see CONFIG_USB_FUNCTIONFS=y is correctly contained in the
.config, but not in the auto.conf.

Please note drivers/usb/gadget/legacy/Kconfig is included from a choice
block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value.

This is probably a similar situation described in commit beaaddb62540
("kconfig: tests: test defconfig when two choices interact").

When sym_calc_choice() is called, the choice symbol forgets the
SYMBOL_DEF_USER unless all of its choice values are explicitly set by
the user.

The choice symbol is given just one chance to recall it because
set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES
is set.

When sym_calc_choice() is called again, the choice symbol forgets it
forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid.
Hence, we cannot call sym_clear_all_valid() again and again.

It is crazy to repeat set and unset of internal flags. However, we
cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;"
Doing so would re-introduce the problem solved by commit 5d09598d488f
("kconfig: fix new choices being skipped upon config update").

To work around the issue, conf_write_autoconf() stopped calling
sym_clear_all_valid().

conf_write() must be changed accordingly. Currently, it clears
SYMBOL_WRITE after the symbol is written into the .config file. This
is needed to prevent it from writing the same symbol multiple times in
case the symbol is declared in two or more locations. I added the new
flag SYMBOL_WRITTEN, to track the symbols that have been written.

Anyway, this is a cheesy workaround in order to suppress the issue
as far as defconfig is concerned.

Handling of choices is totally broken. sym_clear_all_valid() is called
every time a user touches a symbol from the GUI interface. To reproduce
it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch
around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear
from the .config file.

I added the Fixes tag since it is more fatal than before. But, this
has been broken since long long time before, and still it is.
We should take a closer look to fix this correctly somehow.

Fixes: 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing")
Cc: linux-stable <stable@vger.kernel.org> # 4.19+
Reported-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Joonas Kylmälä <joonas.kylmala@iki.fi>


# e3cd5136 11-Jul-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: remove meaningless if-conditional in conf_read()

sym_is_choice(sym) has already been checked by previous if-block:

if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
continue;

Hence, the following code is redundant, and the comment is misleading:

if (!sym_is_choice(sym))
continue;
/* fall through */

It always takes 'continue', never falls though.

Clean up the dead code.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# baa23ec8 03-Jul-2019 Marco Ammon <marco.ammon@fau.de>

kconfig: Fix spelling of sym_is_changable

There is a spelling mistake in "changable", it is corrected to
"changeable" and all call sites are updated accordingly.

Signed-off-by: Marco Ammon <marco.ammon@fau.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# b6f7e9f7 27-May-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: require the argument of --defconfig

Currently, the argument for --defconfig is optional. If the argument
is not passed, the hard-coded default arch/$(ARCH)/defconfig is used.

It no longer happens in Linux since the last users of the default are
gone by the following commits:

- Commit f3e20ad67b4c ("s390: move arch/s390/defconfig to
arch/s390/configs/defconfig")

- Commit 986a13769c4b ("alpha: move arch/alpha/defconfig to
arch/alpha/configs/defconfig")

I want to kill the Linux-specific directory path embedded in the
Kconfig binary.

The --savedefconfig (reverse operation of --defconfig) requires an
argument, so it should not hurt to do likewise for --defconfig.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# aff11cd9 17-May-2019 Alexander Popov <alex.popov@linux.com>

kconfig: Terminate menu blocks with a comment in the generated config

Currently menu blocks start with a pretty header but end with nothing in
the generated config. So next config options stick together with the
options from the menu block.

Let's terminate menu blocks in the generated config with a comment and
a newline if needed. Example:

...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y
# end of Network testing
# end of Networking options

CONFIG_HAMRADIO=y
...

Signed-off-by: Alexander Popov <alex.popov@linux.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 9b9f5948 12-May-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: make conf_get_autoconfig_name() static

This is only used in confdata.c

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# b9d1a8e9 10-May-2019 Jacob Garber <jgarber1@ualberta.ca>

kconfig: use snprintf for formatting pathnames

Valid pathnames will never exceed PATH_MAX, but these file names
are unsanitized and can cause buffer overflow if set incorrectly.
Use snprintf to avoid this. This was flagged during a Coverity scan
of the coreboot project, which also uses kconfig for its build system.

Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 4cb72612 10-May-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: remove useless NULL pointer check in conf_write_dep()

conf_write_dep() has just one caller:

conf_write_dep("include/config/auto.conf.cmd");

"name" always points to a valid string.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 580c5b3e 10-May-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: make parent directories for the saved .config as needed

With menuconfig / nconfig, users can input any file path from the
"Save" menu, but it fails if the parent directory does not exist.

Why not create the parent directory automatically. I think this is
a user-friendly behavior.

I changed the error messages in menuconfig / nconfig.

"Nonexistent directory" is no longer the most likely reason of the
failure. Perhaps, the user specified the existing directory, or
attempted to write to the location without write permission.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 67424f61 10-May-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: do not write .config if the content is the same

Kconfig updates the .config when it exits even if its content is
exactly the same as before. Since its timestamp becomes newer than
that of other build artifacts, additional processing is invoked,
which is annoying.

- syncconfig is invoked to update include/config/auto.conf, etc.

- kernel/configs.o is recompiled if CONFIG_IKCONFIG is enabled,
then vmlinux is relinked as well.

If the .config is not changed at all, we do not have to even
touch it. Just bail out showing "No change to .config".

$ make allmodconfig
scripts/kconfig/conf --allmodconfig Kconfig
#
# configuration written to .config
#
$ make allmodconfig
scripts/kconfig/conf --allmodconfig Kconfig
#
# No change to .config
#

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# ceb7f329 10-May-2019 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: do not accept a directory for configuration output

Currently, conf_write() can be called with a directory name instead
of a file name. As far as I see, this can happen for menuconfig,
nconfig, gconfig.

If it is given with a directory path, conf_write() kindly appends
getenv("KCONFIG_CONFIG"), but this ends up with hacky dir/basename
handling, and screwed up in corner-cases like "what if KCONFIG_CONFIG
is an absolute path?" as discussed before:

https://patchwork.kernel.org/patch/9910037/

Since conf_write() is already messed up, I'd say "do not do it".
Please pass a file path all the time. If a directory path is specified
for the configuration output, conf_write() will simply error out.

Now that the tmp file is created in the same directory as the .config,
the previously reported "what if KCONFIG_CONFIG points to a different
file system?" has been solved.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Nicolas Porcel <nicolasporcel06@gmail.com>


# 558e78e3 21-Dec-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: split some C files out of zconf.y

I want to compile each C file independently instead of including all
of them from zconf.y.

Split out confdata.c, expr.c, symbol.c, and preprocess.c .
These are low-hanging fruits.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 0c874100 18-Dec-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: convert to SPDX License Identifier

All files in lxdialog/ are licensed under GPL-2.0+, and the rest are
under GPL-2.0. I added GPL-2.0 tags to test scripts in tests/.

Documentation/process/license-rules.rst does not suggest anything
about the flex/bison files. Because flex does not accept the C++
comment style at the very top of a file, I used the C style for
zconf.l, and so for zconf.y for consistency.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 2aabbed6 30-Nov-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: remove S_OTHER symbol type and correct dependency tracking

The S_OTHER type could be set only when conf_read_simple() is reading
include/config/auto.conf file.

For example, CONFIG_FOO=y exists in include/config/auto.conf but it is
missing from the currently parsed Kconfig files, sym_lookup() allocates
a new symbol, and sets its type to S_OTHER.

Strangely, it will be set to S_STRING by conf_set_sym_val() a few lines
below while it is obviously bool or tristate type. On the other hand,
when CONFIG_BAR="bar" is being dropped from include/config/auto.conf,
its type remains S_OTHER. Because for_all_symbols() omits S_OTHER
symbols, conf_touch_deps() misses to touch include/config/bar.h

This behavior has been a pretty mystery for me, and digging the git
histroy did not help. At least, touching depfiles is broken for string
type symbols.

I removed S_OTHER entirely, and reimplemented it more simply.

If CONFIG_FOO was visible in the previous syncconfig, but is missing
now, what we want to do is quite simple; just call conf_touch_dep()
to touch include/config/foo.h instead of allocating a new symbol data.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 1508fec8 30-Nov-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: split out code touching a file to conf_touch_dep()

conf_touch_deps() iterates over symbols, touching corresponding
include/config/*.h files as needed.

Split the part that touches a single file into a new helper so it can
be reused.

The new helper, conf_touch_dep(), takes a symbol name as a parameter,
and touches the corresponding include/config/*.h file.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 0849d212 30-Nov-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: rename conf_split_config() to conf_touch_deps()

According to commit 2e3646e51b2d ("kconfig: integrate split config
into silentoldconfig"), this function was named after split-include
tool, which used to exist in old versions of Linux.

Setting aside the historical reason, rename it into a more intuitive
name. This function touches timestamp files under include/config/
in order to interact with the fixdep tool.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 75889e9b 30-Nov-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: remove unneeded setsym label in conf_read_simple()

The two 'goto setsym' statements are reachable only when sym == NULL.

The code below the 'setsym:' label does nothing when sym == NULL
since there is just one if-block guarded by 'if (sym && ...)'.

Hence, 'goto setsym' can be replaced with 'continue'.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 00c864f8 20-Jul-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: allow all config targets to write auto.conf if missing

Currently, only syncconfig creates or updates include/config/auto.conf
and some other files. Other config targets create or update only the
.config file.

When you configure and build the kernel from a pristine source tree,
any config target is followed by syncconfig in the build stage since
include/config/auto.conf is missing.

We are moving compiler tests from Makefile to Kconfig. It means that
parsing Kconfig files will be more costly since Kconfig invokes the
compiler commands internally. Thus, we want to avoid invoking Kconfig
twice (one for *config to create the .config, and one for syncconfig
to synchronize the auto.conf). If auto.conf does not exist, we can
generate all configuration files in the first configuration stage,
which will save the syncconfig in the build stage.

Please note this should be done only when auto.conf is missing. If
*config blindly did this, time stamp files under include/config/ would
be unnecessarily touched, triggering unneeded rebuild of objects.

I assume a scenario like this:

1. You have a source tree that has already been built
with CONFIG_FOO disabled

2. Run "make menuconfig" to enable CONFIG_FOO

3. CONFIG_FOO turns out to be unnecessary.
Run "make menuconfig" again to disable CONFIG_FOO

4. Run "make"

In this case, include/config/foo.h should not be touched since there
is no change in CONFIG_FOO. The sync process should be delayed until
the user really attempts to build the kernel.

This commit has another motivation; I want to suppress the 'No such
file or directory' warning from the 'include' directive.

The top-level Makefile includes auto.conf with '-include' directive,
like this:

ifeq ($(dot-config),1)
-include include/config/auto.conf
endif

This looks strange because auto.conf is mandatory when dot-config is 1.
I guess only the reason of using '-include' is to suppress the warning
'include/config/auto.conf: No such file or directory' when building
from a clean tree. However, this has a side-effect; Make considers
the files included by '-include' are optional. Hence, Make continues
to build even if it fails to generate include/config/auto.conf. I will
change this in the next commit, but the warning message is annoying.
(At least, kbuild test robot reports it as a regression.)

With this commit, Kconfig will generate all configuration files together
with the .config and I guess it is a solution good enough to suppress
the warning.

Note:
GNU Make 4.2 or later does not display the warning from the 'include'
directive if include files are successfully generated. See GNU Make
commit 87a5f98d248f ("[SV 102] Don't show unnecessary include file
errors.") However, older GNU Make versions are still widely used.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 79123b13 20-Jul-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: create directories needed for syncconfig by itself

'make syncconfig' creates some files such as include/config/auto.conf,
include/generate/autoconf.h, etc. but the necessary directory creation
relies on scripts/kconfig/Makefile.

To make Kconfig self-contained, create directories as needed in
conf_write_autoconf().

This change allows scripts/kconfig/Makefile cleanups; syncconfig can
be merged into simple-targets.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 0608182a 20-Jul-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: split out useful helpers in confdata.c

Split out helpers:
is_present() - check if the given path exists
is_dir() - check if the given path exists and it is a directory
make_parent_dir() - create the parent directories of the given path

These helpers will be reused in later commits.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# a2ff4040 20-Jul-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: rename file_write_dep and move it to confdata.c

file_write_dep() is called only from conf_write_autoconf().
Move it from util.c to confdata.c to make it static.
Also, rename it to conf_write_dep() since it should belong to
the group of conf_write* functions.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 5accd7f3 04-Jul-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: handle format string before calling conf_message_callback()

As you see in mconf.c and nconf.c, conf_message_callback() hooks are
likely to end up with the boilerplate of vsnprintf(). Process the
string format before calling conf_message_callback() so that it
receives a simple string.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Dirk Gouders <dirk@gouders.net>


# 693359f7 03-Jul-2018 Dirk Gouders <dirk@gouders.net>

kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE

Over time, the use of the flag SYMBOL_AUTO changed from initially
marking three automatically generated symbols ARCH, KERNELRELEASE and
UNAME_RELEASE to today's effect of protecting symbols from being
written out.

Currently, only symbols of type CHOICE and those with option
defconf_list set have that flag set.

Reflect that change in semantics in the flag's name.

Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 2ae89c7a 02-Jun-2018 Nathan Chancellor <nathan@kernel.org>

kconfig: Avoid format overflow warning from GCC 8.1

In file included from scripts/kconfig/zconf.tab.c:2485:
scripts/kconfig/confdata.c: In function ‘conf_write’:
scripts/kconfig/confdata.c:773:22: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
sprintf(newname, "%s%s", dirname, basename);
^~
scripts/kconfig/confdata.c:773:19: note: assuming directive output of 7 bytes
sprintf(newname, "%s%s", dirname, basename);
^~~~~~
scripts/kconfig/confdata.c:773:2: note: ‘sprintf’ output 1 or more bytes (assuming 4104) into a destination of size 4097
sprintf(newname, "%s%s", dirname, basename);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/kconfig/confdata.c:776:23: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
^~~~~~~~~~~
scripts/kconfig/confdata.c:776:3: note: ‘sprintf’ output between 13 and 4119 bytes into a destination of size 4097
sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Increase the size of tmpname and newname to make GCC happy.

Cc: stable@vger.kernel.org
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 104daea1 28-May-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: reference environment variables directly and remove 'option env='

To get access to environment variables, Kconfig needs to define a
symbol using "option env=" syntax. It is tedious to add a symbol entry
for each environment variable given that we need to define much more
such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability
in Kconfig.

Adding '$' for symbol references is grammatically inconsistent.
Looking at the code, the symbols prefixed with 'S' are expanded by:
- conf_expand_value()
This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list'
- sym_expand_string_value()
This is used to expand strings in 'source' and 'mainmenu'

All of them are fixed values independent of user configuration. So,
they can be changed into the direct expansion instead of symbols.

This change makes the code much cleaner. The bounce symbols 'SRCARCH',
'ARCH', 'SUBARCH', 'KERNELVERSION' are gone.

sym_init() hard-coding 'UNAME_RELEASE' is also gone. 'UNAME_RELEASE'
should be replaced with an environment variable.

ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced
without '$' prefix.

The new syntax is addicted by Make. The variable reference needs
parentheses, like $(FOO), but you can omit them for single-letter
variables, like $F. Yet, in Makefiles, people tend to use the
parenthetical form for consistency / clarification.

At this moment, only the environment variable is supported, but I will
extend the concept of 'variable' later on.

The variables are expanded in the lexer so we can simplify the token
handling on the parser side.

For example, the following code works.

[Example code]

config MY_TOOLCHAIN_LIST
string
default "My tools: CC=$(CC), AS=$(AS), CPP=$(CPP)"

[Result]

$ make -s alldefconfig && tail -n 1 .config
CONFIG_MY_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E"

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Kees Cook <keescook@chromium.org>


# 694c49a7 22-May-2018 Sam Ravnborg <sam@ravnborg.org>

kconfig: drop localization support

The localization support is broken and appears unused.
There is no google hits on the update-po-config target.
And there is no recent (5 years) activity related to the localization.

So lets just drop this as it is no longer used.

Suggested-by: Ulf Magnusson <ulfalizer@gmail.com>
Suggested-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# cd81fc82 16-Feb-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: add xstrdup() helper

We already have xmalloc(), xcalloc(), and xrealloc((). Add xstrdup()
as well to save tedious error handling.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# d717f24d 08-Feb-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: add xrealloc() helper

We already have xmalloc(), xcalloc(). Add xrealloc() as well
to save tedious error handling.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# 84dd95d4 11-Jan-2018 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: make conf_unsaved a local variable of conf_read()

conf_unsaved is initialized by conf_read_simple(), but it is possible
to move it to conf_read() so that it can be a local variable.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>


# b92d804a 15-Dec-2017 Masahiro Yamada <yamada.masahiro@socionext.com>

kconfig: drop 'boolean' keyword

No more users of this keyword. Drop it according to the notice by
commit 6341e62b212a ("kconfig: use bool instead of boolean for type
definition attributes").

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Luis R. Rodriguez <mcgrof@kernel.org>


# a4663911 16-Mar-2016 Paul Bolle <pebolle@tiscali.nl>

kconfig: add unexpected data itself to warning

If the .config parser runs into unexpected data it emits warnings like:
.config:6911:warning: unexpected data

Add the unexpected data itself to this warning. That makes it easier to
discover what is actually going wrong:
.config:6911:warning: unexpected data: CONFOG_CHARGER_TPS65217=m

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Michal Marek <mmarek@suse.com>


# 6b87b70c 14-Jan-2016 Al Viro <viro@ZenIV.linux.org.uk>

unbreak allmodconfig KCONFIG_ALLCONFIG=...

Prior to 3.13 make allmodconfig KCONFIG_ALLCONFIG=/dev/null used
to be equivalent to make allmodconfig; these days it hardwires MODULES to n.
In fact, any KCONFIG_ALLCONFIG that doesn't set MODULES explicitly is
treated as if it set it to n.

Regression had been introduced by commit cfa98f ("kconfig: do not
override symbols already set"); what happens is that conf_read_simple()
does sym_calc_value(modules_sym) on exit, which leaves SYMBOL_VALID set and
has conf_set_all_new_symbols() skip modules_sym.

It's pretty easy to fix - simply move that call of sym_calc_value()
into the callers, except for the ones in KCONFIG_ALLCONFIG handling.
Objections?

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Fixes: cfa98f2e0ae9 ("kconfig: do not override symbols already set")
Signed-off-by: Michal Marek <mmarek@suse.com>


# 35ffd08d 07-Jul-2015 Markus Elfring <elfring@users.sourceforge.net>

kconfig: Delete unnecessary checks before the function call "sym_calc_value"

The sym_calc_value() function tests whether its argument is NULL and then
returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Michal Marek <mmarek@suse.com>


# ad8d40cd 24-Feb-2015 Michal Marek <mmarek@suse.cz>

kconfig: Remove unnecessary prototypes from headers

Signed-off-by: Michal Marek <mmarek@suse.cz>


# b6a2ab2c 12-Jan-2015 Colin Ian King <colin.king@canonical.com>

kconfig: use va_end to match corresponding va_start

Although on some systems va_end is a no-op, it is good practice
to use va_end, especially since the manual states:

"Each invocation of va_start() must be matched by a corresponding
invocation of va_end() in the same function."

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 5d2acfc7 07-Apr-2014 Josh Triplett <josh@joshtriplett.org>

kconfig: make allnoconfig disable options behind EMBEDDED and EXPERT

"make allnoconfig" exists to ease testing of minimal configurations.
Documentation/SubmitChecklist includes a note to test with allnoconfig.
This helps catch missing dependencies on common-but-not-required
functionality, which might otherwise go unnoticed.

However, allnoconfig still leaves many symbols enabled, because they're
hidden behind CONFIG_EMBEDDED or CONFIG_EXPERT. For instance, allnoconfig
still has CONFIG_PRINTK and CONFIG_BLOCK enabled, so drivers don't
typically get build-tested with those disabled.

To address this, introduce a new Kconfig option "allnoconfig_y", used on
symbols which only exist to hide other symbols. Set it on CONFIG_EMBEDDED
(which then selects CONFIG_EXPERT). allnoconfig will then disable all the
symbols hidden behind those.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 04b19b77 06-Aug-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: silence warning when parsing auto.conf when a symbol has changed type

When a symbol changes type from tristate to bool, and was previously set to
'm', a subsequent silentoldconfig would warn about inconsistency, such as:

include/config/auto.conf:3014:warning: symbol value 'm' invalid for
HOTPLUG_PCI_PCIE

Seen by Linus with the merge in aa8032b (sequence to reproduce by Michal):
git checkout 1fe0135
make mrproper
make allmodconfig
make silentoldconfig
git checkout aa8032b
make allmodconfig
make silentoldconfig

Since HOTPLUG_PCI_PCIE changed from tristate to bool in aa8032b, it was
previously set to 'm' in auto.conf by the first allmodconfig+silentoldconfig,
but then was set to 'y' by the second allmodconfig. Then the second
silentoldconfig prints the warning.

The warning in this case is a spurious warning, which happens at the time
kconfig tries to detect symbols that have changed, to touch the empty
header files in include/config used for dependency-tracking by make.

Silence the warning when we read the old auto.conf file, since it is
perfectly legit that a symbol changed type since the previous call.

Thread in:
http://marc.info/?l=linux-pci&m=137569198904000&w=2

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>


# 490f1617 25-Jun-2013 Yann E. MORIN <yann.morin.1998@free.fr>

Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG"

This reverts commit 8357b48549e17b3e4e402c7f977b65708922e60f.

It breaks more stuff than it fixes.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 8357b485 18-Jun-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG

Currently, randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG
is specified.

For example, given those two files (Thomas' test-case):

---8<--- Config.test.in
config OPTIONA
bool "Option A"

choice
prompt "This is a choice"

config CHOICE_OPTIONA
bool "Choice Option A"

config CHOICE_OPTIONB
bool "Choice Option B"

endchoice

config OPTIONB
bool "Option B"
---8<--- Config.test.in

---8<--- config.defaults
CONFIG_OPTIONA=y
---8<--- config.defaults

And running:
./scripts/kconfig/conf --randconfig Config.test.in

does properly randomise the two choice symbols (and the two booleans).

However, running:
KCONFIG_ALLCONFIG=config.defaults \
./scripts/kconfig/conf --randconfig Config.test.in

does *not* reandomise the two choice entries, and only CHOICE_OPTIONA
will ever be selected. (OPTIONA will always be set (expected), and
OPTIONB will be be properly randomised (expected).)

This patch defers setting that a choice has a value until a symbol for
that choice is indeed set, so that choices are properly randomised when
KCONFIG_ALLCONFIG is set, but not if a symbol for that choice is set.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>

---
Changes v3 -> v4
- fix previous issue where some choices would not be set, which would
cause silentoldconfig to ask for them and was then breaking this
workflow (as reported by Arnd and Sedat):
KCONFIG_ALLCONFIG=foo.defconfig make randconfig
make silentoldconfig </dev/nullo
which I have tested (3h28min!) with:
touch defconfig
for(( i=0; i<10000; i++ )); do
KCONFIG_ALLCONFIG=$(pwd)/defconfig make randconfig >/dev/null 2>&1
make silentoldconfig </dev/null >/dev/null 2>&1 || break
done
which did not break at all.
- change done in v3 (below) is already fixed by a previous patch

Changes v2 -> v3
- ensure only one symbol is set in a choice

Changes v1 -> v2:
- further postpone setting that a choice has a value until
one is indeed set
- do not print symbols that are part of an invisible choice


# 3b9a19e0 28-Apr-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: loop as long as we changed some symbols in randconfig

Because of choice-in-a-choice constructs, it can happen that not all
symbols are assigned a value during randconfig, leading in rare cases
to this situation:

---8<--- choice-in-choice.in
choice
bool "A/B/C"
config A
bool "A"

config B
bool "B"
if B
choice
bool "E/F"
config E
bool "E"
config F
bool "F"
endchoice
endif # B

config C
bool "C"
endchoice
---8<---

$ ./scripts/kconfig/conf --randconfig choice-in-choice.in
[--SNIP--]
$ ./scripts/kconfig/conf --silentoldconfig choice-in-choice.in </dev/null
[--SNIP--]
A/B/C
1. A (A)
> 2. B (B)
3. C (C)
choice[1-3]: 2
E/F
> 1. E (E) (NEW)
2. F (F) (NEW)
choice[1-2]: aborted!

Console input/output is redirected. Run 'make oldconfig' to update
configuration.

Fix this by looping in randconfig for as long as some symbol gets assigned
a value.

Note: this was spotted with the USB EHCI Debug Device Gadget (USB_G_DBGP),
which uses this choice-in-a-choice construct, and exhibits this problem.
The example above is just a stripped-down minimalist test-case.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# e6abf12a 28-Apr-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig/conf: fix randconfig setting multiple symbols in a choice

Currently, randconfig may set more than one symbol in a given choice.
Given this config file:
config A
bool "A"
if A
choice
bool "B/C/D"
config B
bool "B"
config C
bool "C"
config D
bool "D"
endchoice
endif # A

Then randconfig generates such .config files (case where A is not set is not
shown below for brevity), and where only the right-most .config is valid:
CONFIG_A=y CONFIG_A=y CONFIG_A=y
CONFIG_B=y CONFIG_B=y CONFIG_B=y
CONFIG_C=y # CONFIG_C is not set # CONFIG_C is not set
# CONFIG_D is not set CONFIG_D=y # CONFIG_D is not set

That is, in a randomised choice, the first symbol is always selected,
and at most one other symbol may be selected.

This is due to symbol randomised in a choice not being properly flagged
as having a value.

Fix that by flagging those symbols adequately: have a user-defined value,
and be not valid (to force recalculation of the symbol).

Note: if the choice is not conditional, then the randomisation is properly
done.

Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Matthieu CASTET <matthieu.castet@parrot.com>
[yann.morin.1998@free.fr: independently re-done the same patch as Matthieu,
as pointed out by Sedat]
Cc: Arnaud Lacombe <lacombar@gmail.com>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# fbe98bb9 06-Jun-2013 Arve Hjønnevåg <arve@android.com>

kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on

The defconfig and Kconfig combination below, which is based on 3.10-rc4
Kconfigs, resulted in several options getting set to "m" instead of "y".

defconfig.choice:
---8<---
CONFIG_MODULES=y
CONFIG_USB_ZERO=y
---8<---

Kconfig.choice:
---8<---
menuconfig MODULES
bool "Enable loadable module support"

config CONFIGFS_FS
tristate "Userspace-driven configuration filesystem"

config OCFS2_FS
tristate "OCFS2 file system support"
depends on CONFIGFS_FS
select CRC32

config USB_LIBCOMPOSITE
tristate
select CONFIGFS_FS

choice
tristate "USB Gadget Drivers"
default USB_ETH

config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
select USB_LIBCOMPOSITE

config USB_ETH
tristate "Ethernet Gadget (with CDC Ethernet support)"
select USB_LIBCOMPOSITE

endchoice

config CRC32
tristate "CRC32/CRC32c functions"
default y

choice
prompt "CRC32 implementation"
depends on CRC32
default CRC32_SLICEBY8

config CRC32_SLICEBY8
bool "Slice by 8 bytes"

endchoice
---8<---

$ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice

would result in:

.config:
---8<---
CONFIG_MODULES=y
CONFIG_CONFIGFS_FS=m
CONFIG_USB_LIBCOMPOSITE=m
CONFIG_USB_ZERO=m
CONFIG_CRC32=y
CONFIG_CRC32_SLICEBY8=y
---8<---

when the expected result would be:

.config:
---8<---
CONFIG_MODULES=y
CONFIG_CONFIGFS_FS=y
CONFIG_USB_LIBCOMPOSITE=y
CONFIG_USB_ZERO=y
CONFIG_CRC32=y
CONFIG_CRC32_SLICEBY8=y
---8<---

Signed-off-by: Arve Hjønnevåg <arve@android.com>
[yann.morin.1998@free.fr: add the resulting .config to commit log,
remove unneeded USB_GADGET from the defconfig]
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>


# 23a5dfda 26-Apr-2013 Yann E. MORIN <yann.morin.1998@free.fr>

Revert "kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG"

This reverts commit 422c809f03f043d0950d8362214818e956a9daee.
It causes more harm than it solves issues.

Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Greg KH <greg@kroah.com>


# e43956e6 13-Apr-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: implement KCONFIG_PROBABILITY for randconfig

Currently the odds to set each symbol is (rounded):
booleans: y: 50% n: 50%
tristates: y: 33% m: 33% n: 33%

Introduce a KCONFIG_PROBABILITY environment variable to tweak the
probabilities (in percentage), as such:
KCONFIG_PROBABILITY y:n split y:m:n split
-----------------------------------------------------------------
[1] unset or empty 50 : 50 33 : 33 : 34
[2] N N : 100-N N/2 : N/2 : 100-N
N:M N+M : 100-(N+M) N : M : 100-(N+M)
N:M:L N : 100-N M : L : 100-(M+L)

[1] The current behaviour is kept as default, for backward compatibility
[2] The solution initially implemented by Peter for Buildroot, see:
http://git.buildroot.org/buildroot/commit/?id=3435c1afb5

Signed-off-by: Peter Korsgaard <jacmet@uclibc.org>
[yann.morin.1998@free.fr: add to Documentation/]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# 422c809f 10-Mar-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG

Currently, randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG
is specified.

For example, given those two files (Thomas' test-case):

---8<--- Config.test.in
config OPTIONA
bool "Option A"

choice
prompt "This is a choice"

config CHOICE_OPTIONA
bool "Choice Option A"

config CHOICE_OPTIONB
bool "Choice Option B"

endchoice

config OPTIONB
bool "Option B"
---8<--- Config.test.in

---8<--- config.defaults
CONFIG_OPTIONA=y
---8<--- config.defaults

And running:
./scripts/kconfig/conf --randconfig Config.test.in

does properly randomise the two choice symbols (and the two booleans).

However, running:
KCONFIG_ALLCONFIG=config.defaults \
./scripts/kconfig/conf --randconfig Config.test.in

does *not* reandomise the two choice entries, and only CHOICE_OPTIONA
will ever be selected. (OPTIONA will always be set (expected), and
OPTIONB will be be properly randomised (expected).)

This patch defers setting that a choice has a value until a symbol for
that choice is indeed set, so that choices are properly randomised when
KCONFIG_ALLCONFIG is set, but not if a symbol for that choice is set.

Also, as a side-efect, this patch fixes the following case:

---8<---
choice
config OPTION_A
bool "Option A"
config OPTION_B
bool "Option B"
config OPTION_C
bool "Option C"
endchoice
---8<---

which could previously generate such .config files:

---8<--- ---8<---
CONFIG_OPTION_A=y CONFIG_OPTION_A=y
CONFIG_OPTION_B=y # CONFIG_OPTION_B is not set
# CONFIG_OPTION_C is not set CONFIG_OPTION_C=y
---8<--- ---8<---

Ie., the first entry in a choice is always set, plus zero or one of
the other options may be set.

This patch ensures that only one option may be set for a choice.

Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Arnaud Lacombe <lacombar@gmail.com>

---
Changes v2 -> v3
- ensure only one symbol is set in a choice

Changes v1 -> v2:
- further postpone setting that a choice has a value until
one is indeed set
- do not print symbols that are part of an invisible choice


# cfa98f2e 24-Apr-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: do not override symbols already set

For randconfig, if a list of required symbols is specified with
KCONFIG_ALLCONFIG, such symbols do not "have a value" as per
sym_has_value(), but have the "valid" flag set.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# 61fa0e17 24-Apr-2013 Yann E. MORIN <yann.morin.1998@free.fr>

kconfig: fix randconfig tristate detection

Because the modules' symbole (CONFIG_MODULES) may not yet be set when
we check a symbol's tristate capabilty, we'll always find that tristate
symbols are booleans, even if we randomly decided that to enable modules:
sym_get_type(sym) always return boolean for tristates when modules_sym
has not been previously set to 'y' *and* its value calculated *and* its
visibility calculated, both of which only occur after we randomly assign
values to symbols.

Fix that by looking at the raw type of symbols. Tristate set to 'm' will
be promoted to 'y' when their values will be later calculated.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>


# 1a7a8c6f 13-Jul-2012 Cody Schafer <cody@linux.vnet.ibm.com>

kconfig: allow long lines in config file

For some config options (CONFIG_EXTRA_FIRMWARE, for example), the length
of a config file line can exceed the 1024 byte buffer.

Switch from fgets to compat_getline to fix. compat_getline is an
internally implimented getline work-alike for portability purposes.

Signed-off-by: Cody Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# e4757cab 12-Apr-2012 Paul Gortmaker <paul.gortmaker@windriver.com>

kconfig: delete last traces of __enabled_ from autoconf.h

We've now fixed IS_ENABLED() and friends to not require any special
"__enabled_" prefixed versions of the normal Kconfig options, so delete
the last traces of them being generated.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a9596135 12-Apr-2012 Paul Gortmaker <paul.gortmaker@windriver.com>

Revert "kconfig: fix __enabled_ macros definition for invisible and un-selected symbols"

This reverts commit 953742c8fe8ac45be453fee959d7be40cd89f920.

Dumping two lines into autoconf.h for all existing Kconfig options
results in a giant file (~16k lines) we have to process each time we
compile something. We've weaned IS_ENABLED() and similar off of
requiring the __enabled_ definitions so now we can revert the change
which caused all the extra lines.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 5d09598d 23-Jan-2012 Arnaud Lacombe <lacombar@gmail.com>

kconfig: fix new choices being skipped upon config update

Running `oldconfig' after any of the following configuration change:

either trivial addition, such as:

config A
bool "A"

choice
prompt "Choice ?"
depends on A

config CHOICE_B
bool "Choice B"

config CHOICE_C
bool "Choice C"
endchoice

or more tricky change:

OLD KCONFIG | NEW KCONFIG
|
| config A
| bool "A"
|
choice | choice
prompt "Choice ?" | prompt "Choice ?"
|
config CHOICE_C | config CHOICE_C
bool "Choice C" | bool "Choice C"
|
config CHOICE_D | config CHOICE_D
bool "Choice D" | bool "Choice D"
endchoice |
| config CHOICE_E
| bool "Choice E"
| depends on A
| endchoice

will not cause the choice to be considered as NEW, and thus not be
asked. The cause of this behavior is that choice's novelty are computed
statically right after the saved configuration has been read. At this
point, the new dependency's value is still unknown and asserted to be
`no'. Moreover, no update to this decision is made afterward.

Correct this by dynamically evaluating a choice's novelty, and removing the
static evaluation.

Reported-and-tested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 70cc01e7 22-Oct-2011 Peter Foley <pefoley2@verizon.net>

kconfig: use xfwrite wrapper function to silence warnings

Use the xfwrite wrapper function defined in lkc.h to check the return value of
fwrite and silence these warnings.

HOSTCC scripts/kconfig/zconf.tab.o
scripts/kconfig/zconf.tab.c: In function 'header_print_comment':
/usr/src/lto/scripts/kconfig/confdata.c:551:10: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result
scripts/kconfig/zconf.tab.c: In function 'kconfig_print_comment':
/usr/src/lto/scripts/kconfig/confdata.c:467:10: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result

Signed-off-by: Peter Foley <pefoley2@verizon.net>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 953742c8 15-Aug-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: fix __enabled_ macros definition for invisible and un-selected symbols

__enabled_<sym-name> are only generated on visible or selected entries, do not
reflect the purpose of its introduction.

Fix this by always generating these entries for named symbol.

Reported-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# 2a11c8ea 20-Jul-2011 Michal Marek <mmarek@suse.cz>

kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()

Replace the config_is_*() macros with a variant that allows for grepping
for usage of CONFIG_* options in the code. Usage:

if (IS_ENABLED(CONFIG_NUMA))

or

#if IS_ENABLED(CONFIG_NUMA)

The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y'
or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if
the option is 'm'. Only boolean and tristate options are supported.

Reviewed-by: Arnaud Lacombe <lacombar@gmail.com>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# eb4cf5a6 14-Jul-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: fix missing "0x" prefix from S_HEX symbol in autoconf.h

The specialized printer for headers (espectially autoconf.h) is missing
fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not
warn for such missing prefix, this code is needed. Fix this.

In the same time, fix some nits in `header_print_symbol()'.

Cc: Randy Dunlap <rdunlap@xenotime.net>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>

Broken-by: Arnaud Lacombe <lacombar@gmail.com>
Reported-by: Randy Dunlap <rdunlap@xenotime.net>
Reported-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# e54e692b 15-May-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: introduce specialized printer

Make conf_write_symbol() grammar agnostic to be able to use it from different
code path. These path pass a printer callback which will print a symbol's name
and its value in different format.

conf_write_symbol()'s job become mostly only to prepare a string for the
printer. This avoid to have to pass specialized flag to generic
functions

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
[mmarek: rebased on top of de12518 (kconfig: autogenerated config_is_xxx
macro)]
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 5a6f8d2b 01-Jun-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: nuke LKC_DIRECT_LINK cruft

This interface is not (and has never been ?) used by any frontend, just get rid
of it.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# 10a4b277 01-Jun-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: add missing <stdarg.h> inclusion

This header is needed when using va_{start,end,copy}(3) functions family.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# 75f1468b 30-May-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: fix return code for invalid boolean symbol in conf_set_sym_val()

Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# d8fc3200 30-May-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: annotate non-trivial fall-trough

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>


# 4c54f0f8 17-May-2011 Michal Marek <mmarek@suse.cz>

kconfig: Only generate config_is_xxx for bool and tristate options

For strings and integers, the config_is_xxx macros are useless and
sometimes misleading:

#define CONFIG_INITRAMFS_SOURCE ""
#define config_is_initramfs_source() 1

Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# bdebd489 15-May-2011 Arnaud Lacombe <lacombar@gmail.com>

kconfig: do not record timestamp in .config

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# de125187 05-May-2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

kconfig: autogenerated config_is_xxx macro

this will allow to use to use

if(config_is_xxx())
if(config_is_xxx_module())

in the code instead of

#ifdef CONFIG_xxx
#ifdef CONFIG_xxx_MODULE

and now let the compiler remove the non usefull code and not the
pre-processor

as done in the mach-types for arm as exmaple

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Acked-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# c33724a4 28-Apr-2009 Michal Marek <mmarek@suse.cz>

kconfig: Do not record timestamp in auto.conf and autoconf.h

Timestamps in file data are useless and there is already one in .config

Signed-off-by: Michal Marek <mmarek@suse.cz>


# 579fb8e7 04-Dec-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: fix typos

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 0dce6310 04-Dec-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: nuke second argument of conf_write_symbol()

Replacing S_TRISTATE by S_BOOLEAN is a no-op for conf_write_symbol().

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
[mmarek: Fix unused variable warning in conf_write()]
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 6e71fabe 04-Dec-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: do not define AUTOCONF_INCLUDED

AUTOCONF_INCLUDED is not checked is not used within the tree and its parent
header, `autoconf.h', is safe to be re-included.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# b595076a 01-Nov-2010 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

tree-wide: fix comment/printk typos

"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 1408b15b 22-Sep-2010 Will Newton <will.newton@gmail.com>

kconfig: Use PATH_MAX instead of 128 for path buffer sizes.

This prevents the buffers being overflowed when using a config
file with a long name. PATH_MAX is used elsewhere in the same
file, so use it here as well.

Signed-off-by: Will Newton <will.newton@imgtec.com>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 8bea7548 30-Sep-2010 Naohiro Aota <naota@elisp.net>

kconfig: Don't go out from read config loop when you read new symbol

commit 8baefd30b5b0101aa07aa75da44a9eee881eed28 of linux-next replaced
a `switch()' statement with some `if()' statements, but left `break's
in the `switch()' statement untouched. This cause read config loop to
exit and so "make oldconfig" is not much usable (see below).

> $ make oldconfig
><snip>
> scripts/kconfig/conf --oldconfig Kconfig
> #
> # using defaults found in /boot/config-2.6.34-ccs-r1
> #
> *
> * Restart config...
> *
> *
> * General setup
> *
> Prompt for development and/or incomplete code/drivers (EXPERIMENTAL) [N/y/?] (NEW)

(I've already have "CONFIG_EXPERIMENTAL=y" in the old config file. But
that's not read here.)

This patch should fix this problem.

Signed-off-by: Naohiro Aota <naota@elisp.net>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 0954828f 17-Aug-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: replace KERNELVERSION usage by the mainmenu's prompt

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Michal Marek <mmarek@suse.cz>


# ffb5957b 14-Aug-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: allow build-time definition of the internal config prefix

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Michal Marek <mmarek@suse.cz>


# 8baefd30 23-Aug-2010 Arnaud Lacombe <lacombar@gmail.com>

kconfig: replace a `switch()' statement by a more flexible `if()' statement

With the upcoming dynamical configuration prefix, we can no longer assume that
the prefix will start by a 'C'. As such, we can no longer hardcode this value in
the `case ...:', so replace the `switch() { ... }' statement by a more flexible
'if () { ... }' statement.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Michal Marek <mmarek@suse.cz>


# 42368c37 17-Aug-2010 Michal Marek <mmarek@suse.cz>

kconfig: Allow frontends to display messages themselves

Signed-off-by: Michal Marek <mmarek@suse.cz>


# 94bedeca 16-Aug-2010 Arnaud Lacombe <lacombar@gmail.com>

kbuild: confdata.c explicitly reference errno, thus need <errno.h>

This fixes:
% gmake LKC_GENPARSER=1 menuconfig
[...]
scripts/kconfig/confdata.c:739: error: 'errno' undeclared (first use in this function)
scripts/kconfig/confdata.c:739: error: (Each undeclared identifier is reported only once
scripts/kconfig/confdata.c:739: error: for each function it appears in.)
scripts/kconfig/confdata.c:739: error: 'ENOENT' undeclared (first use in this function)

triggered on NetBSD.

Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 84062dd3 14-Aug-2010 Sam Ravnborg <sam@ravnborg.org>

kconfig: fix savedefconfig with choice marked optional

savedefconfig failed to save the correct minimal config
when it encountered a choice marked optional.

Consider following minimal configuration:
$cat Kconfig
choice
prompt "choice"
optional

config A
bool "a"

config B
bool "b"

endchoice

$cat .config | grep -v ^#
CONFIG_A=y

$conf --savedefconfig=defconfig Kconfig

would before this fix result in an empty file, because
kconfig would assume that CONFIG_A=y is a default value.
But because the choice is optional the default is that
both A and B are =n.

Fix so we handle optional choices correct.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# bf5e327a 04-Aug-2010 Jean Sacren <sakiwit@gmail.com>

kconfig: Fix warning: ignoring return value of 'fwrite'

This fix facilitates fwrite() in both confdata.c and expr.c, either it
succeeds in writing, or an error occurs, or the end of file is reached.

Signed-off-by: Jean Sacren <sakiwit@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# a64b44ea 12-Aug-2010 Sam Ravnborg <sam@ravnborg.org>

kconfig: fix tristate choice with minimal config

If a minimal config did not specify the value
of all choice values, the resulting configuration
could have wrong values.

Consider following example:
config M
def_bool y
option modules
choice
prompt "choice list"
config A
tristate "a"
config B
tristate "b"
endchoice

With a defconfig like this:
CONFIG_M=y
CONFIG_A=y

The resulting configuration would have

CONFIG_A=m

which was unexpected.

The problem was not not all choice values were set and thus
kconfig calculated a wrong value.

The fix is to set all choice values when we
read a defconfig files.

conf_set_all_new_symbols() is refactored such that
random choice values are now handled by a dedicated function.
And new choice values are set by set_all_choice_values().

This was not the minimal fix, but the fix that resulted
in the most readable code.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reported-by: Arve Hjønnevåg <arve@android.com>
Tested-by: Arve Hjønnevåg <arve@android.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 801690ca 12-Aug-2010 Sam Ravnborg <sam@ravnborg.org>

kconfig: fix savedefconfig for tristate choices

savedefconfig failed to save choice symbols equal to 'y'
for tristate choices.
This resulted in this value being lost.

In particular is fixes an issue where

make ARCH=avr32 atngw100_defconfig
make ARCH=avr32 savedefconfig
cp defconfig arch/avr32/configs/atngw100_defconfig
make ARCH=avr32 atngw100_defconfig
diff -u .config .config.old

failed to produce an identical .config.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 7cf3d73b 31-Jul-2010 Sam Ravnborg <sam@ravnborg.org>

kconfig: add savedefconfig

savedefconfig will save a minimal config to a file
named "defconfig".

The config symbols are saved in the same order as
they appear in the menu structure so it should
be possible to map them to the relevant menus
if desired.

The implementation was tested against several minimal
configs for arm which was created using brute-force.

There was one regression related to default numbers
which had their valid range further limited by another symbol.

Sample:

config FOO
int "foo"
default 4

config BAR
int "bar"
range 0 FOO

If FOO is set to 3 then BAR cannot take a value higher than 3.
But the current implementation will set BAR equal to 4.

This is seldomly used and the final configuration is OK,
and the fix was non-trivial.
So it was documented in the code and left as is.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 49192f26 31-Jul-2010 Sam Ravnborg <sam@ravnborg.org>

kconfig: code refactoring in confdata.c

Add a a few local functions to avoid some code duplication
No functional changes.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# ac1ffde1 27-Jul-2010 Ulf Magnusson <ulfalizer.lkml@gmail.com>

kconfig: fix MODULES-related bug in case of no .config

There seems to be a kconfig bug due to MODULES not always being
evaluated if no .config is found. Take the following Kconfig as an
example:

config MODULES
def_bool y

config FOO
def_tristate m

With no .config, the following configuration is generated:

CONFIG_MODULES=y
CONFIG_FOO=y

With an empty .config, the following:

CONFIG_MODULES=y
CONFIG_FOO=m

Tristate choice statements can also exhibit the problem, due to having an
implicit rev_dep (select) containing "m".

The problem is that MODULES is never evaluted in conf_read_simple() unless
there's a .config. The following patch fixes this.

Signed-off-by: Ulf Magnusson <ulfalizer.lkml@gmail.com>
Reviewed-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 1244b41d 22-Jul-2010 Peter Korsgaard <jacmet@sunsite.dk>

kconfig: make randconfig fair for booleans

Give boolean symbols a 50% chance of getting enabled, rather than 67%.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# bc081dd6 07-Dec-2009 Michal Marek <mmarek@suse.cz>

kbuild: generate modules.builtin

To make it easier for module-init-tools and scripts like mkinitrd to
distinguish builtin and missing modules, install a modules.builtin file
listing all builtin modules. This is done by generating an additional
config file (tristate.conf) with tristate options set to uppercase 'Y'
or 'M'. If we source that config file, the builtin modules appear in
obj-Y.

Signed-off-by: Michal Marek <mmarek@suse.cz>


# 264a2683 17-Oct-2009 Sam Ravnborg <sam@ravnborg.org>

kbuild: move autoconf.h to include/generated

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>


# 4356f489 18-Sep-2009 Trevor Keith <tsrk@tsrk.net>

kbuild: add static to prototypes

Warnings found via gcc -Wmissing-prototypes.

Signed-off-by: Trevor Keith <tsrk@tsrk.net>
Acked-by: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 12122f62 17-May-2009 Markus Heidelberg <markus.heidelberg@web.de>

kconfig: do not hardcode "include/config/auto.conf" filename

Regardless of KCONFIG_AUTOCONFIG, the filename written as a Make target
into "include/config/auto.conf.cmd" was always the default one.

Of course this doesn't make it work for the Kernel kbuild system, since
there the filename is hardcoded at several places in the Makefiles.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 184832c9 15-Mar-2009 Sam Ravnborg <sam@ravnborg.org>

kconfig: fix randconfig for choice blocks

Ingo Molnar reported that 'make randconfig' was not covering
choice blocks properly, resulting in certain config options
being left out of randconfig testing altogether.

With the following patch we:
- properly randomize choice value for normal choice blocks
- properly randomize for multi choice blocks
- added several comments to explain what is going on

The root cause of the bug was that SYMBOL_VALID was set on the
symbol representing the choice block so clearing this did
the trick initially.
But testign revealed a few more issues that is now fixed.

Reported-by: Ingo Molnar <mingo@elte.hu>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# ce97e13e 25-Oct-2008 Al Viro <viro@ZenIV.linux.org.uk>

fix allmodconfig breakage

If you use KCONFIG_ALLCONFIG (even with empty file) you get broken
allmodconfig/allyesconfig; CONFIG_MODULES gets turned off, with obvious
massive fallout.

Breakage had been introduced when conf_set_all_new_symbols() got used
for allmodconfig et.al.

What happens is that sym_calc_value(modules_sym) done in
conf_read_simple() sets SYMBOL_VALID on both modules_sym and MODULES.
When we get to conf_set_all_new_symbols(), we set sym->def[S_DEF_USER]
on everything, but it has no effect on sym->curr for the symbols that
already have SYMBOL_VALID - these are stuck.

Solution: use sym_clear_all_valid() in there. Note that it makes
reevaluation of modules_sym redundant - sym_clear_all_valid() will do
that itself.

[ Fixes http://bugzilla.kernel.org/show_bug.cgi?id=11512, says Alexey ]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 661b0680 28-Sep-2008 zippel@linux-m68k.org <zippel@linux-m68k.org>

kconfig: readd lost change count

Commit f072181e6403b0fe2e2aa800a005497b748fd284 ("kconfig: drop the
""trying to assign nonexistent symbol" warning") simply dropped the
warnings, but it does a little more than that, it also marks the current
.config as needed saving, so add this back.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# f072181e 04-Aug-2008 Sam Ravnborg <sam@ravnborg.org>

kconfig: drop the ""trying to assign nonexistent symbol" warning

They really stand out now that make *config is less chatty - and
they are generally ignored - so drop them.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Adrian Bunk <bunk@kernel.org>


# dc7862e5 05-May-2008 Roman Zippel <zippel@linux-m68k.org>

kconfig: set all new symbols automatically

Add conf_set_all_new_symbols() which set all symbols (which don't have a
value yet) to a specifed value.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 7a962923 13-Jan-2008 Roman Zippel <zippel@linux-m68k.org>

kconfig: explicitly introduce expression list

Rename E_CHOICE to E_LIST to explicitly add support for expression
lists. Add a helper macro expr_list_for_each_sym to more easily iterate
over the list.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# d6ee3576 07-Jan-2008 Sam Ravnborg <sam@ravnborg.org>

kconfig: rename E_OR & friends to avoid name clash

We had macros named the same as a set of enumeration values.
It is legal code but very confusing to read - so rename
the macros from E_* to EXPR_*

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>


# d84876f9 03-Jan-2008 Jan Engelhardt <jengelh@computergmbh.de>

kconfig: allow overriding symbols

Allow config variables in .config to override earlier ones in the same
file. In other words,

# CONFIG_SECURITY is not defined
CONFIG_SECURITY=y

will activate it. This makes it a bit easier to do

cat original-config myconfig myconfig2 ... >.config;
and run *config as expected.

Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Randy Dunlap <randy.dunlap@oracle.com>


# 6840999b 17-Nov-2007 Sam Ravnborg <sam@ravnborg.org>

x86: simplify "make ARCH=x86" and fix kconfig all.config

Simplify "make ARCH=x86" and fix kconfig so we again can set 64BIT in
all.config.

For a fix the diffstat is nice:
6 files changed, 3 insertions(+), 36 deletions(-)

The patch reverts these commits:
- 0f855aa64b3f63d35a891510cf7db932a435c116 ("kconfig: add helper to set
config symbol from environment variable")
- 2a113281f5cd2febbab21a93c8943f8d3eece4d3 ("kconfig: use $K64BIT to
set 64BIT with all*config targets")

Roman Zippel pointed out that kconfig supported string compares so
the additional complexity introduced by the above two patches were
not needed.

With this patch we have following behaviour:

# make {allno,allyes,allmod,rand}config [ARCH=...]
option \ host arch | 32bit | 64bit
=====================================================
./. | 32bit | 64bit
ARCH=x86 | 32bit | 32bit
ARCH=i386 | 32bit | 32bit
ARCH=x86_64 | 64bit | 64bit

The general rule are that ARCH= and native architecture takes
precedence over the configuration.

So make ARCH=i386 [whatever] will always build a 32-bit kernel
no matter what the configuration says. The configuration will
be updated to 32-bit if it was configured to 64-bit and the
other way around.

This behaviour is consistent with previous behaviour so no
suprises here.

make ARCH=x86 will per default result in a 32-bit kernel but as
the only ARCH= value x86 allow the user to select between 32-bit
and 64-bit using menuconfig.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Andreas Herrmann <aherrman@arcor.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 80ef88d6 17-Nov-2007 Sam Ravnborg <sam@ravnborg.org>

x86: simplify "make ARCH=x86" and fix kconfig all.config

Simplify "make ARCH=x86" and fix kconfig so we again
can set 64BIT in all.config.

For a fix the diffstat is nice:
6 files changed, 3 insertions(+), 36 deletions(-)

The patch reverts these commits:
0f855aa64b3f63d35a891510cf7db932a435c116
-> kconfig: add helper to set config symbol from environment variable

2a113281f5cd2febbab21a93c8943f8d3eece4d3
-> kconfig: use $K64BIT to set 64BIT with all*config targets

Roman Zippel pointed out that kconfig supported string
compares so the additional complexity introduced by the
above two patches were not needed.

With this patch we have following behaviour:

# make {allno,allyes,allmod,rand}config [ARCH=...]
option \ host arch | 32bit | 64bit
=====================================================
./. | 32bit | 64bit
ARCH=x86 | 32bit | 32bit
ARCH=i386 | 32bit | 32bit
ARCH=x86_64 | 64bit | 64bit

The general rule are that ARCH= and native architecture
takes precedence over the configuration.
So make ARCH=i386 [whatever] will always build a 32-bit
kernel no matter what the configuration says.
The configuration will be updated to 32-bit if it was
configured to 64-bit and the other way around.

This behaviour is consistent with previous behaviour so
no suprises here.

make ARCH=x86 will per default result in a 32-bit kernel
but as the only ARCH= value x86 allow the user to select
between 32-bit and 64-bit using menuconfig.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Cc: Andreas Herrmann <aherrman@arcor.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>


# 0f855aa6 10-Nov-2007 Sam Ravnborg <sam@ravnborg.org>

kconfig: add helper to set config symbol from environment variable

Add conf_set_env_sym() that can set an already defined symbol
based on the value of an environment variable.

Unknown symbols are silently ignored.
A warning is printed if the value of the environment variable
is unexpected.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>


# 9c900a9c 10-Nov-2007 Sam Ravnborg <sam@ravnborg.org>

kconfig: factor out code in confdata.c

This patch introduce no functional changes.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>


# d8982ba1 09-Jul-2007 Roman Zippel <zippel@linux-m68k.org>

kconfig: reset generated values only if Kconfig and .config agree.

Normally generated values (Kconfig entries without a prompt) are cleared as
they are regenerated anyway and so they appear as new should they become
visible and defaults work as expected (once a value is set defaults aren't
used anymore).

The detection whether a value is generated or not is only based on its
visibility status, which can quickly change for a lot of symbols by just
removing a single line from .config or adding a dependency to Kconfig as you
noticed.

The patch now suppresses this logic when .config and Kconfig aren't in sync
and .config needs to be updated, so that you can remove now a random value
from .config and oldconfig won't reask for many other values.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 3b354c55 13-Dec-2006 Karsten Wiese <annabellesgarden@yahoo.de>

[PATCH] kconfig: add "void conf_set_changed_callback(void (*fn)(void))", use it in qconf.cc

Added function sets "void (*conf_changed_callback)(void)". Call it, if
.config's changed state changes. Use above in qconf.cc to set gui's
save-widget's sensitvity.

Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# bfc10001 13-Dec-2006 Karsten Wiese <annabellesgarden@yahoo.de>

[PATCH] kconfig: make sym_change_count static, let it be altered by 2 functions only

Those two functions are
void sym_set_change_count(int count)
and
void sym_add_change_count(int count)

All write accesses to sym_change_count are replaced by calls to above
functions.

Variable and changer-functions are moved to confdata.c. IMO thats ok, as
sym_change_count is an attribute of the .config's change state.

Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# b3214293 13-Dec-2006 Karsten Wiese <annabellesgarden@yahoo.de>

[PATCH] kconfig: new function "bool conf_get_changed(void)"

Run "make xconfig" on a freshly untarred kernel-tree. Look at the floppy disk
icon of the qt application, that has just started: Its in a normal, active
state.

Mouse click on it: .config is being saved.

This patch series changes things so taht
after the mouse click on the floppy disk icon, the icon is greyed out.
If you mouse click on it now, nothing happens.

If you change some CONFIG_*, the floppy disk icon returns to "active state",
that is, if you mouse click it now, .config is written.

This patch:

Returns sym_change_count to reflect the .config's change state.
All read only accesses of
sym_change_count
are replaced by calls to
conf_get_changed()
.
mconfig.c is manipulated to ask for saving only when
conf_get_changed() returned true.

Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 9a3d0fe8 01-Oct-2006 Sam Ravnborg <sam@neptun.ravnborg.org>

kconfig: fix saving alternate kconfig file in parent dir

This fixes bugzilla entry: 7182
http://bugzilla.kernel.org/show_bug.cgi?id=7182

With this patch we no longer append the directory part twice
before saving the config file.
This patch has been sent to Roman Zippel for review with no feedback.
It is so obviously simple that this should be OK to apply it anyway.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# d3660a8c 13-Jul-2006 Matthew Wilcox <willy@infradead.org>

kconfig: support DOS line endings

Kconfig doesn't currently handle config files with DOS line endings.
While these are, of course, an abomination, etc, etc, it can be handy
to not have to convert them first. It's also a tiny patch and even adds
support for lines ending in just \r or even \n\r.

Signed-off-by: Matthew Wilcox <matthew@wil.cx>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 002d27b1 13-Jul-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: correct oldconfig for unset choice options

oldconfig currently ignores unset choice options and doesn't ask for them.
Correct the SYMBOL_DEF_USER flag of the choice symbol to be only set if
it's set for all values.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 14cdd3c4 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: KCONFIG_OVERWRITECONFIG

If you set KCONFIG_OVERWRITECONFIG in environment, Kconfig will not break
symlinks when .config is a symlink to somewhere else.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# face4374 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: add defconfig_list/module option

This makes it possible to change two options which were hardcoded sofar.
1. Any symbol can now take the role of CONFIG_MODULES
2. The more useful option is to change the list of default file names,
which kconfig uses to load the base configuration if .config isn't
available.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 2e3646e5 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: integrate split config into silentoldconfig

Now that kconfig can load multiple configurations, it becomes simple to
integrate the split config step, by simply comparing the new .config file with
the old auto.conf (and then saving the new auto.conf). A nice side effect is
that this saves a bit of disk space and cache, as no data needs to be read
from or saved into the splitted config files anymore (e.g. include/config is
now 648KB instead of 5.2MB).

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 669bfad9 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: allow loading multiple configurations

Extend conf_read_simple() so it can load multiple configurations.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 0c1822e6 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: allow multiple default values per symbol

Extend struct symbol to allow storing multiple default values, which can be
used to hold multiple configurations.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# c955ccaf 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: fix .config dependencies

This fixes one of the worst kbuild warts left - the broken dependencies used
to check and regenerate the .config file. This was done via an indirect
dependency and the .config itself had an empty command, which can cause make
not to reread the changed .config file.

Instead of this we generate now a new file include/config/auto.conf from
.config, which is used for kbuild and has the proper dependencies. It's also
the main make target now for all files generated during this step (and thus
replaces include/linux/autoconf.h).

This also means we can now relax the syntax requirements for the .config file
and we don't have to rewrite it all the time, i.e. silentoldconfig only
writes .config now when it's necessary to keep it in sync with the Kconfig
files and even this can be suppressed by setting the environment variable
KCONFIG_NOSILENTUPDATE, so the update can (and must) be done manually.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# ddc97cac 08-Jun-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: improve config load/save output

During loading special case the first common case (.config), be silent about
it and otherwise mark it as a change that requires saving. Instead output
that the file has been changed. IOW if conf does nothing (special), it's
silent.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# b5ac4817 09-Apr-2006 Roman Zippel <zippel@linux-m68k.org>

kconfig: fix typo in change count initialization

Configuration needs saving when either of these conditions is true.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# dc9a49a4 09-Mar-2006 Jan Beulich <JBeulich@novell.com>

kconfig: fix time ordering of writes to .kconfig.d and include/linux/autoconf.h

Since .kconfig.d is used as a make dependency of include/linux/autoconf.h, it
should be written earlier than the header file, to avoid a subsequent rebuild
to consider the header outdated.

Signed-Off-By: Jan Beulich <jbeulich@novell.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# 2244cbd8 15-Jan-2006 Sam Ravnborg <sam@mars.ravnborg.org>

kbuild: create .kernelrelease at *config step

To enable 'make kernelrelease' earlier now create .kernelrelease when
one of the *config targets are used.
Also introduce KERNELVERSION - only user is kconfig.
KERNELVERSION was needed to display kernel version in menuconfig -
KERNELRELEASE is not valid until configuration has completed.
kconfig files modified to use KERNELVERSION.
Bug reported by: Rene Rebe <rene@exactcode.de>

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>


# c1a0f5e3 08-Nov-2005 Roman Zippel <zippel@linux-m68k.org>

[PATCH] kconfig: stricter error checking for .config

Add some more checks during the parsing of .config, so that after parsing
sym_change_count reflects the correct state whether the .config is correct and
in sync with the Kconfig or if it needs saving.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 90389160 08-Nov-2005 Roman Zippel <zippel@linux-m68k.org>

[PATCH] kconfig: preset config during all*config

Allow to force setting of config variables during all{no,mod,yes,random}config
to a specific value. For that conf first checks the KCONFIG_ALLCONFIG
environment variable for a file name, otherwise it checks for
all{no,mod,yes,random}.config and all.config. The file is a normal config
file, which presets the config variables, but they are still subject to normal
dependency checks.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 48b9d03c 25-Jun-2005 J.A. Magallon <jamagallon@able.es>

[PATCH] Kill signed chars

scripts/ is full of mismatches between char* params an signed char* arguments,
and viceversa. gcc4 now complaints loud about this. Patch below deletes all
those 'signed'.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>


# 3b9fa093 05-May-2005 Arnaldo Carvalho de Melo <acme@ghostprotocols.net>

[PATCH] Kconfig i18n support

This patch adds i18n support for make *config, allowing users to have the
config process in their own language.

No printk was harmed in the process, don't worry, so all the bug reports,
kernel messages, etc, remain in english, just the user tools to configure
the kernel are internationalized.

Users not interested in translations can just unset the related LANG,
LC_ALL, etc env variables and have the config process in plain english,
something like:

LANG= make menuconfig

is enough for having the whole config process in english. Or just don't
install any translation file.

Translations for brazilian portuguese are being done by a team of
volunteers at:

http://www.visionflex.inf.br/kernel_ptbr/pmwiki.php/Principal/Traducoes

To start the translation process:

make update-po-config

This will generate the pot template named scripts/kconfig/linux.pot,
copy it to, say, ~/es.po, to start the translation for spanish.

To test your translation, as root issue this command:

msgfmt -o /usr/share/locale/es/LC_MESSAGES/linux.mo ~/es.po

Replace "es" with your language code.

Then execute, for instance:

make menuconfig

The current patch doesn't use any optimization to reduce the size of the
generated .mo file, it is possible to use the config option as a key, but
this doesn't prevent the current patch from being used or the translations
done under the current scheme to be in any way lost if we chose to do any
kind of keying.

Thanks to Fabricio Vaccari for starting the pt_BR (brazilian portuguese)
translation effort, Thiago Maciera for helping me with the gconf.cc (QT
frontent) i18n coding and to all the volunteers that are already working on
the first translation, to pt_BR.

I left the question on whether to ship the translations with the stock kernel
sources to be discussed here, please share your suggestions.

Signed-off-by: Arnaldo Carvalho de Melo <acme@conectiva.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org
Signed-off-by: Andrew Morton <akpm@osdl.org>


# 1da177e4 16-Apr-2005 Linus Torvalds <torvalds@ppc970.osdl.org>

Linux-2.6.12-rc2

Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.

Let it rip!