Skip to content

Commit 5b41978

Browse files
committed
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kconfig updates from Michal Marek: "This is the kconfig part of kbuild for v3.12-rc1: - post-3.11 search code fixes and micro-optimizations - CONFIG_MODULES is no longer a special case; this is needed to eventually fix the bug that using KCONFIG_ALLCONFIG breaks allmodconfig - long long is used to store hex and int values - make silentoldconfig no longer warns when a symbol changes from tristate to bool (it's a job for make oldconfig) - scripts/diffconfig updated to work with newer Pythons - scripts/config does not rely on GNU sed extensions" * 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kconfig: do not allow more than one symbol to have 'option modules' kconfig: regenerate bison parser kconfig: do not special-case 'MODULES' symbol diffconfig: Update script to support python versions 2.5 through 3.3 diffconfig: Gracefully exit if the default config files are not present modules: do not depend on kconfig to set 'modules' option to symbol MODULES kconfig: silence warning when parsing auto.conf when a symbol has changed type scripts/config: use sed's POSIX interface kconfig: switch to "long long" for sanity kconfig: simplify symbol-search code kconfig: don't allocate n+1 elements in temporary array kconfig: minor style fixes in symbol-search code kconfig/[mn]conf: shorten title in search-box kconfig: avoid multiple calls to strlen Documentation/kconfig: more concise and straightforward search explanation
2 parents a22a0fd + e062781 commit 5b41978

12 files changed

Lines changed: 413 additions & 345 deletions

File tree

‎Documentation/kbuild/kconfig-language.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ applicable everywhere (see syntax).
147147
- "modules"
148148
This declares the symbol to be used as the MODULES symbol, which
149149
enables the third modular state for all config symbols.
150+
At most one symbol may have the "modules" option set.
150151

151152
- "env"=<value>
152153
This imports the environment variable into Kconfig. It behaves like

‎Documentation/kbuild/kconfig.txt‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,9 @@ Searching in menuconfig:
175175
/^hotplug
176176

177177
When searching, symbols are sorted thus:
178-
- exact match first: an exact match is when the search matches
179-
the complete symbol name;
180-
- alphabetical order: when two symbols do not match exactly,
181-
they are sorted in alphabetical order (in the user's current
182-
locale).
178+
- first, exact matches, sorted alphabetically (an exact match
179+
is when the search matches the complete symbol name);
180+
- then, other matches, sorted alphabetically.
183181
For example: ^ATH.K matches:
184182
ATH5K ATH9K ATH5K_AHB ATH5K_DEBUG [...] ATH6KL ATH6KL_DEBUG
185183
[...] ATH9K_AHB ATH9K_BTCOEX_SUPPORT ATH9K_COMMON [...]

‎init/Kconfig‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,7 @@ config BASE_SMALL
16701670

16711671
menuconfig MODULES
16721672
bool "Enable loadable module support"
1673+
option modules
16731674
help
16741675
Kernel modules are small pieces of compiled code which can
16751676
be inserted in the running kernel, rather than being

‎scripts/config‎

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,52 @@ checkarg() {
6262
fi
6363
}
6464

65+
txt_append() {
66+
local anchor="$1"
67+
local insert="$2"
68+
local infile="$3"
69+
local tmpfile="$infile.swp"
70+
71+
# sed append cmd: 'a\' + newline + text + newline
72+
cmd="$(printf "a\\%b$insert" "\n")"
73+
74+
sed -e "/$anchor/$cmd" "$infile" >"$tmpfile"
75+
# replace original file with the edited one
76+
mv "$tmpfile" "$infile"
77+
}
78+
79+
txt_subst() {
80+
local before="$1"
81+
local after="$2"
82+
local infile="$3"
83+
local tmpfile="$infile.swp"
84+
85+
sed -e "s/$before/$after/" "$infile" >"$tmpfile"
86+
# replace original file with the edited one
87+
mv "$tmpfile" "$infile"
88+
}
89+
90+
txt_delete() {
91+
local text="$1"
92+
local infile="$2"
93+
local tmpfile="$infile.swp"
94+
95+
sed -e "/$text/d" "$infile" >"$tmpfile"
96+
# replace original file with the edited one
97+
mv "$tmpfile" "$infile"
98+
}
99+
65100
set_var() {
66101
local name=$1 new=$2 before=$3
67102

68103
name_re="^($name=|# $name is not set)"
69104
before_re="^($before=|# $before is not set)"
70105
if test -n "$before" && grep -Eq "$before_re" "$FN"; then
71-
sed -ri "/$before_re/a $new" "$FN"
106+
txt_append "^$before=" "$new" "$FN"
107+
txt_append "^# $before is not set" "$new" "$FN"
72108
elif grep -Eq "$name_re" "$FN"; then
73-
sed -ri "s:$name_re.*:$new:" "$FN"
109+
txt_subst "^$name=.*" "$new" "$FN"
110+
txt_subst "^# $name is not set" "$new" "$FN"
74111
else
75112
echo "$new" >>"$FN"
76113
fi
@@ -79,7 +116,8 @@ set_var() {
79116
undef_var() {
80117
local name=$1
81118

82-
sed -ri "/^($name=|# $name is not set)/d" "$FN"
119+
txt_delete "^$name=" "$FN"
120+
txt_delete "^# $name is not set" "$FN"
83121
}
84122

85123
if [ "$1" = "--file" ]; then

‎scripts/diffconfig‎

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import sys, os
1111

1212
def usage():
13-
print """Usage: diffconfig [-h] [-m] [<config1> <config2>]
13+
print("""Usage: diffconfig [-h] [-m] [<config1> <config2>]
1414
1515
Diffconfig is a simple utility for comparing two .config files.
1616
Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@ Example usage:
3333
EXT2_FS y -> n
3434
LOG_BUF_SHIFT 14 -> 16
3535
PRINTK_TIME n -> y
36-
"""
36+
""")
3737
sys.exit(0)
3838

3939
# returns a dictionary of name/value pairs for config items in the file
@@ -54,23 +54,23 @@ def print_config(op, config, value, new_value):
5454
if merge_style:
5555
if new_value:
5656
if new_value=="n":
57-
print "# CONFIG_%s is not set" % config
57+
print("# CONFIG_%s is not set" % config)
5858
else:
59-
print "CONFIG_%s=%s" % (config, new_value)
59+
print("CONFIG_%s=%s" % (config, new_value))
6060
else:
6161
if op=="-":
62-
print "-%s %s" % (config, value)
62+
print("-%s %s" % (config, value))
6363
elif op=="+":
64-
print "+%s %s" % (config, new_value)
64+
print("+%s %s" % (config, new_value))
6565
else:
66-
print " %s %s -> %s" % (config, value, new_value)
66+
print(" %s %s -> %s" % (config, value, new_value))
6767

6868
def main():
6969
global merge_style
7070

7171
# parse command line args
7272
if ("-h" in sys.argv or "--help" in sys.argv):
73-
usage()
73+
usage()
7474

7575
merge_style = 0
7676
if "-m" in sys.argv:
@@ -79,23 +79,27 @@ def main():
7979

8080
argc = len(sys.argv)
8181
if not (argc==1 or argc == 3):
82-
print "Error: incorrect number of arguments or unrecognized option"
82+
print("Error: incorrect number of arguments or unrecognized option")
8383
usage()
8484

8585
if argc == 1:
8686
# if no filenames given, assume .config and .config.old
8787
build_dir=""
88-
if os.environ.has_key("KBUILD_OUTPUT"):
88+
if "KBUILD_OUTPUT" in os.environ:
8989
build_dir = os.environ["KBUILD_OUTPUT"]+"/"
90-
9190
configa_filename = build_dir + ".config.old"
9291
configb_filename = build_dir + ".config"
9392
else:
9493
configa_filename = sys.argv[1]
9594
configb_filename = sys.argv[2]
9695

97-
a = readconfig(file(configa_filename))
98-
b = readconfig(file(configb_filename))
96+
try:
97+
a = readconfig(open(configa_filename))
98+
b = readconfig(open(configb_filename))
99+
except (IOError):
100+
e = sys.exc_info()[1]
101+
print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))
102+
usage()
99103

100104
# print items in a but not b (accumulate, sort and print)
101105
old = []
@@ -121,8 +125,7 @@ def main():
121125

122126
# now print items in b but not in a
123127
# (items from b that were in a were removed above)
124-
new = b.keys()
125-
new.sort()
128+
new = sorted(b.keys())
126129
for config in new:
127130
print_config("+", config, None, b[config])
128131

‎scripts/kconfig/confdata.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
140140
sym->flags |= def_flags;
141141
break;
142142
}
143-
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
143+
if (def != S_DEF_AUTO)
144+
conf_warning("symbol value '%s' invalid for %s",
145+
p, sym->name);
144146
return 1;
145147
case S_OTHER:
146148
if (*p != '"') {
@@ -161,7 +163,8 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
161163
memmove(p2, p2 + 1, strlen(p2));
162164
}
163165
if (!p2) {
164-
conf_warning("invalid string found");
166+
if (def != S_DEF_AUTO)
167+
conf_warning("invalid string found");
165168
return 1;
166169
}
167170
/* fall through */
@@ -172,7 +175,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
172175
sym->def[def].val = strdup(p);
173176
sym->flags |= def_flags;
174177
} else {
175-
conf_warning("symbol value '%s' invalid for %s", p, sym->name);
178+
if (def != S_DEF_AUTO)
179+
conf_warning("symbol value '%s' invalid for %s",
180+
p, sym->name);
176181
return 1;
177182
}
178183
break;

‎scripts/kconfig/mconf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ static void search_conf(void)
401401
struct subtitle_part stpart;
402402

403403
title = str_new();
404-
str_printf( &title, _("Enter %s (sub)string or regexp to search for "
405-
"(with or without \"%s\")"), CONFIG_, CONFIG_);
404+
str_printf( &title, _("Enter (sub)string or regexp to search for "
405+
"(with or without \"%s\")"), CONFIG_);
406406

407407
again:
408408
dialog_clear();

‎scripts/kconfig/menu.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,15 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
197197

198198
void menu_add_option(int token, char *arg)
199199
{
200-
struct property *prop;
201-
202200
switch (token) {
203201
case T_OPT_MODULES:
204-
prop = prop_alloc(P_DEFAULT, modules_sym);
205-
prop->expr = expr_alloc_symbol(current_entry->sym);
202+
if (modules_sym)
203+
zconf_error("symbol '%s' redefines option 'modules'"
204+
" already defined by symbol '%s'",
205+
current_entry->sym->name,
206+
modules_sym->name
207+
);
208+
modules_sym = current_entry->sym;
206209
break;
207210
case T_OPT_DEFCONFIG_LIST:
208211
if (!sym_defconfig_list)

‎scripts/kconfig/nconf.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ static void search_conf(void)
695695
int dres;
696696

697697
title = str_new();
698-
str_printf( &title, _("Enter %s (sub)string or regexp to search for "
699-
"(with or without \"%s\")"), CONFIG_, CONFIG_);
698+
str_printf( &title, _("Enter (sub)string or regexp to search for "
699+
"(with or without \"%s\")"), CONFIG_);
700700

701701
again:
702702
dres = dialog_inputbox(main_window,

0 commit comments

Comments
 (0)