From a9b722847872d43595d072d7fd550f08fe6764fd Mon Sep 17 00:00:00 2001 From: Anders Roxell Date: Mon, 12 Nov 2018 09:38:55 +0100 Subject: [PATCH 01/39] scripts/kconfig/merge_config: don't redefine 'y' to 'm' In today's merge_config.sh the order of the config fragment files dictates the output of a config option. With this approach we will get different .config files depending on the order of the config fragment files. So doing something like: $ ./merge/kconfig/merge_config.sh selftest.config drm.config Where selftest.config defines DRM=y and drm.config defines DRM=m, the result will be "DRM=m". Rework to add a switch to get builtin '=y' precedence over modules '=m', this will result in "DRM=y". If we do something like this: $ ./merge/kconfig/merge_config.sh -y selftest.config drm.config Suggested-by: Arnd Bergmann Signed-off-by: Anders Roxell Signed-off-by: Masahiro Yamada --- scripts/kconfig/merge_config.sh | 37 ++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index 0ef906499646..9b89791b202c 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -22,6 +22,7 @@ clean_up() { rm -f $TMP_FILE + rm -f $MERGE_FILE exit } trap clean_up HUP INT TERM @@ -32,6 +33,7 @@ usage() { echo " -m only merge the fragments, do not execute the make command" echo " -n use allnoconfig instead of alldefconfig" echo " -r list redundant entries when merging fragments" + echo " -y make builtin have precedence over modules" echo " -O dir to put generated output files. Consider setting \$KCONFIG_CONFIG instead." echo echo "Used prefix: '$CONFIG_PREFIX'. You can redefine it with \$CONFIG_ environment variable." @@ -40,6 +42,7 @@ usage() { RUNMAKE=true ALLTARGET=alldefconfig WARNREDUN=false +BUILTIN=false OUTPUT=. CONFIG_PREFIX=${CONFIG_-CONFIG_} @@ -64,6 +67,11 @@ while true; do shift continue ;; + "-y") + BUILTIN=true + shift + continue + ;; "-O") if [ -d $2 ];then OUTPUT=$(echo $2 | sed 's/\/*$//') @@ -106,32 +114,45 @@ SED_CONFIG_EXP1="s/^\(${CONFIG_PREFIX}[a-zA-Z0-9_]*\)=.*/\1/p" SED_CONFIG_EXP2="s/^# \(${CONFIG_PREFIX}[a-zA-Z0-9_]*\) is not set$/\1/p" TMP_FILE=$(mktemp ./.tmp.config.XXXXXXXXXX) +MERGE_FILE=$(mktemp ./.merge_tmp.config.XXXXXXXXXX) echo "Using $INITFILE as base" cat $INITFILE > $TMP_FILE # Merge files, printing warnings on overridden values -for MERGE_FILE in $MERGE_LIST ; do - echo "Merging $MERGE_FILE" - if [ ! -r "$MERGE_FILE" ]; then - echo "The merge file '$MERGE_FILE' does not exist. Exit." >&2 +for ORIG_MERGE_FILE in $MERGE_LIST ; do + echo "Merging $ORIG_MERGE_FILE" + if [ ! -r "$ORIG_MERGE_FILE" ]; then + echo "The merge file '$ORIG_MERGE_FILE' does not exist. Exit." >&2 exit 1 fi + cat $ORIG_MERGE_FILE > $MERGE_FILE CFG_LIST=$(sed -n -e "$SED_CONFIG_EXP1" -e "$SED_CONFIG_EXP2" $MERGE_FILE) for CFG in $CFG_LIST ; do grep -q -w $CFG $TMP_FILE || continue PREV_VAL=$(grep -w $CFG $TMP_FILE) NEW_VAL=$(grep -w $CFG $MERGE_FILE) - if [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then - echo Value of $CFG is redefined by fragment $MERGE_FILE: + BUILTIN_FLAG=false + if [ "$BUILTIN" = "true" ] && [ "${NEW_VAL#CONFIG_*=}" = "m" ] && [ "${PREV_VAL#CONFIG_*=}" = "y" ]; then + echo Previous value: $PREV_VAL + echo New value: $NEW_VAL + echo -y passed, will not demote y to m + echo + BUILTIN_FLAG=true + elif [ "x$PREV_VAL" != "x$NEW_VAL" ] ; then + echo Value of $CFG is redefined by fragment $ORIG_MERGE_FILE: echo Previous value: $PREV_VAL echo New value: $NEW_VAL echo elif [ "$WARNREDUN" = "true" ]; then - echo Value of $CFG is redundant by fragment $MERGE_FILE: + echo Value of $CFG is redundant by fragment $ORIG_MERGE_FILE: + fi + if [ "$BUILTIN_FLAG" = "false" ]; then + sed -i "/$CFG[ =]/d" $TMP_FILE + else + sed -i "/$CFG[ =]/d" $MERGE_FILE fi - sed -i "/$CFG[ =]/d" $TMP_FILE done cat $MERGE_FILE >> $TMP_FILE done From 75889e9be78febab9991f9c07fdf09d128562bf5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Nov 2018 18:15:48 +0900 Subject: [PATCH 02/39] 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 --- scripts/kconfig/confdata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 91d0a5c014ac..1e35529d4eeb 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -363,7 +363,7 @@ load: sym = sym_find(line + 2 + strlen(CONFIG_)); if (!sym) { sym_add_change_count(1); - goto setsym; + continue; } } else { sym = sym_lookup(line + 2 + strlen(CONFIG_), 0); @@ -397,7 +397,7 @@ load: sym = sym_find(line + strlen(CONFIG_)); if (!sym) { sym_add_change_count(1); - goto setsym; + continue; } } else { sym = sym_lookup(line + strlen(CONFIG_), 0); @@ -416,7 +416,7 @@ load: continue; } -setsym: + if (sym && sym_is_choice_value(sym)) { struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); switch (sym->def[def].tri) { From 0849d212e39523e2289c2a6d685b899f944746eb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Nov 2018 18:15:49 +0900 Subject: [PATCH 03/39] 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 --- scripts/kconfig/confdata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 1e35529d4eeb..4c76d561d383 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -906,7 +906,7 @@ static int conf_write_dep(const char *name) return 0; } -static int conf_split_config(void) +static int conf_touch_deps(void) { const char *name; char path[PATH_MAX+1]; @@ -1028,7 +1028,7 @@ int conf_write_autoconf(int overwrite) conf_write_dep("include/config/auto.conf.cmd"); - if (conf_split_config()) + if (conf_touch_deps()) return 1; out = fopen(".tmpconfig", "w"); From 1508fec82e394149212aca836dd925d7e8fa3228 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Nov 2018 18:15:50 +0900 Subject: [PATCH 04/39] 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 --- scripts/kconfig/confdata.c | 92 ++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 4c76d561d383..39dfe463de15 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -74,6 +74,47 @@ static int make_parent_dir(const char *path) return 0; } +static char depfile_path[PATH_MAX]; +static size_t depfile_prefix_len; + +/* touch depfile for symbol 'name' */ +static int conf_touch_dep(const char *name) +{ + int fd, ret; + const char *s; + char *d, c; + + /* check overflow: prefix + name + ".h" + '\0' must fit in buffer. */ + if (depfile_prefix_len + strlen(name) + 3 > sizeof(depfile_path)) + return -1; + + d = depfile_path + depfile_prefix_len; + s = name; + + while ((c = *s++)) + *d++ = (c == '_') ? '/' : tolower(c); + strcpy(d, ".h"); + + /* Assume directory path already exists. */ + fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) { + if (errno != ENOENT) + return -1; + + ret = make_parent_dir(depfile_path); + if (ret) + return ret; + + /* Try it again. */ + fd = open(depfile_path, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd == -1) + return -1; + } + close(fd); + + return 0; +} + struct conf_printer { void (*print_symbol)(FILE *, struct symbol *, const char *, void *); void (*print_comment)(FILE *, const char *, void *); @@ -909,21 +950,16 @@ static int conf_write_dep(const char *name) static int conf_touch_deps(void) { const char *name; - char path[PATH_MAX+1]; - char *s, *d, c; struct symbol *sym; - int res, i, fd; + int res, i; + + strcpy(depfile_path, "include/config/"); + depfile_prefix_len = strlen(depfile_path); name = conf_get_autoconfig_name(); conf_read_simple(name, S_DEF_AUTO); sym_calc_value(modules_sym); - if (make_parent_dir("include/config/foo.h")) - return 1; - if (chdir("include/config")) - return 1; - - res = 0; for_all_symbols(i, sym) { sym_calc_value(sym); if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name) @@ -975,42 +1011,12 @@ static int conf_touch_deps(void) * different from 'no'). */ - /* Replace all '_' and append ".h" */ - s = sym->name; - d = path; - while ((c = *s++)) { - c = tolower(c); - *d++ = (c == '_') ? '/' : c; - } - strcpy(d, ".h"); - - /* Assume directory path already exists. */ - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == -1) { - if (errno != ENOENT) { - res = 1; - break; - } - - if (make_parent_dir(path)) { - res = 1; - goto out; - } - - /* Try it again. */ - fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (fd == -1) { - res = 1; - break; - } - } - close(fd); + res = conf_touch_dep(sym->name); + if (res) + return res; } -out: - if (chdir("../..")) - return 1; - return res; + return 0; } int conf_write_autoconf(int overwrite) From 2aabbed6774f231c57f8ae6bc4f856fb2a75cd6a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Nov 2018 18:15:51 +0900 Subject: [PATCH 05/39] 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 --- scripts/kconfig/confdata.c | 33 ++++++++++++++------------------- scripts/kconfig/expr.h | 4 ++-- scripts/kconfig/symbol.c | 3 --- 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 39dfe463de15..9ef135735cfa 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -227,14 +227,6 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) conf_warning("symbol value '%s' invalid for %s", p, sym->name); return 1; - case S_OTHER: - if (*p != '"') { - for (p2 = p; *p2 && !isspace(*p2); p2++) - ; - sym->type = S_STRING; - goto done; - } - /* fall through */ case S_STRING: if (*p++ != '"') break; @@ -253,7 +245,6 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) /* fall through */ case S_INT: case S_HEX: - done: if (sym_string_valid(sym, p)) { sym->def[def].val = xstrdup(p); sym->flags |= def_flags; @@ -434,17 +425,22 @@ load: if (*p2 == '\r') *p2 = 0; } - if (def == S_DEF_USER) { - sym = sym_find(line + strlen(CONFIG_)); - if (!sym) { + + sym = sym_find(line + strlen(CONFIG_)); + if (!sym) { + if (def == S_DEF_AUTO) + /* + * Reading from include/config/auto.conf + * If CONFIG_FOO previously existed in + * auto.conf but it is missing now, + * include/config/foo.h must be touched. + */ + conf_touch_dep(line + strlen(CONFIG_)); + else sym_add_change_count(1); - continue; - } - } else { - sym = sym_lookup(line + strlen(CONFIG_), 0); - if (sym->type == S_UNKNOWN) - sym->type = S_OTHER; + continue; } + if (sym->flags & def_flags) { conf_warning("override: reassigning to symbol %s", sym->name); } @@ -710,7 +706,6 @@ static void conf_write_symbol(FILE *fp, struct symbol *sym, const char *str; switch (sym->type) { - case S_OTHER: case S_UNKNOWN: break; case S_STRING: diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 7c329e179007..2b7e222b0784 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -62,7 +62,7 @@ struct symbol_value { }; enum symbol_type { - S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER + S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING }; /* enum values are used as index to symbol.def[] */ @@ -131,7 +131,7 @@ struct symbol { struct expr_value implied; }; -#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) +#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) #define SYMBOL_CONST 0x0001 /* symbol is const */ #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 703b9b899ee9..2e6bf362d164 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -61,8 +61,6 @@ const char *sym_type_name(enum symbol_type type) return "string"; case S_UNKNOWN: return "unknown"; - case S_OTHER: - break; } return "???"; } @@ -757,7 +755,6 @@ const char *sym_get_string_default(struct symbol *sym) return str; case S_STRING: return str; - case S_OTHER: case S_UNKNOWN: break; } From 0cbe3ac439bfe3e6d0f65b006044f84ce7f3e4d0 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 30 Nov 2018 18:15:52 +0900 Subject: [PATCH 06/39] kconfig: remove k_invalid from expr_parse_string() return type The only possibility of k_invalid being returned was when expr_parse_sting() parsed S_OTHER type symbol. This actually never happened, and this is even clearer since S_OTHER has gone. Clean up unreachable code. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index e1a39e90841d..57ebf71291a7 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -980,7 +980,6 @@ enum string_value_kind { k_string, k_signed, k_unsigned, - k_invalid }; union string_value { @@ -1011,13 +1010,10 @@ static enum string_value_kind expr_parse_string(const char *str, val->u = strtoull(str, &tail, 16); kind = k_unsigned; break; - case S_STRING: - case S_UNKNOWN: + default: val->s = strtoll(str, &tail, 0); kind = k_signed; break; - default: - return k_invalid; } return !errno && !*tail && tail > str && isxdigit(tail[-1]) ? kind : k_string; @@ -1073,13 +1069,7 @@ tristate expr_calc_value(struct expr *e) if (k1 == k_string || k2 == k_string) res = strcmp(str1, str2); - else if (k1 == k_invalid || k2 == k_invalid) { - if (e->type != E_EQUAL && e->type != E_UNEQUAL) { - printf("Cannot compare \"%s\" and \"%s\"\n", str1, str2); - return no; - } - res = strcmp(str1, str2); - } else if (k1 == k_unsigned || k2 == k_unsigned) + else if (k1 == k_unsigned || k2 == k_unsigned) res = (lval.u > rval.u) - (lval.u < rval.u); else /* if (k1 == k_signed && k2 == k_signed) */ res = (lval.s > rval.s) - (lval.s < rval.s); From 77c1c0fa8b1477c5799bdad65026ea5ff676da44 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:44 +0900 Subject: [PATCH 07/39] kconfig: fix file name and line number of warn_ignored_character() Currently, warn_ignore_character() displays invalid file name and line number. The lexer should use current_file->name and yylineno, while the parser should use zconf_curname() and zconf_lineno(). This difference comes from that the lexer is always going ahead of the parser. The parser needs to look ahead one token to make a shift/reduce decision, so the lexer is requested to scan more text from the input file. This commit fixes the warning message from warn_ignored_character(). [Test Code] ----(Kconfig begin)---- / -----(Kconfig end)----- [Output] Before the fix: :0:warning: ignoring unsupported character '/' After the fix: Kconfig:1:warning: ignoring unsupported character '/' Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 25bd2b89fe3f..eeac64ccc730 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -73,7 +73,7 @@ static void warn_ignored_character(char chr) { fprintf(stderr, "%s:%d:warning: ignoring unsupported character '%c'\n", - zconf_curname(), zconf_lineno(), chr); + current_file->name, yylineno, chr); } %} From fbac5977d81cb2b2b7e37b11c459055d9585273c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:45 +0900 Subject: [PATCH 08/39] kconfig: fix memory leak when EOF is encountered in quotation An unterminated string literal followed by new line is passed to the parser (with "multi-line strings not supported" warning shown), then handled properly there. On the other hand, an unterminated string literal at end of file is never passed to the parser, then results in memory leak. [Test Code] ----------(Kconfig begin)---------- source "Kconfig.inc" config A bool "a" -----------(Kconfig end)----------- --------(Kconfig.inc begin)-------- config B bool "b\No new line at end of file ---------(Kconfig.inc end)--------- [Summary from Valgrind] Before the fix: LEAK SUMMARY: definitely lost: 16 bytes in 1 blocks ... After the fix: LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks ... Eliminate the memory leak path by handling this case. Of course, such a Kconfig file is wrong already, so I will add an error message later. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index eeac64ccc730..c2f577d71964 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -221,6 +221,8 @@ n [A-Za-z0-9_-] } <> { BEGIN(INITIAL); + yylval.string = text; + return T_WORD_QUOTE; } } From 413cd19d81fd675c6932abf91fe2b54d5ae72c7d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:46 +0900 Subject: [PATCH 09/39] kconfig: require T_EOL to reduce visible statement All line-oriented statements should be reduced when seeing a T_EOL token. I guess missing T_EOL for the "visible" statement is just a mistake. This commit decreases one shift/reduce conflict. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 22fceb264cf5..c28f1a8f721d 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; %} -%expect 30 +%expect 29 %union { @@ -461,7 +461,7 @@ visibility_list: | visibility_list T_EOL ; -visible: T_VISIBLE if_expr +visible: T_VISIBLE if_expr T_EOL { menu_add_visibility($2); }; From be3c8075978a420b6eae944250bf336aa11d4964 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:47 +0900 Subject: [PATCH 10/39] kconfig: remove unneeded pattern matching to whitespaces Whitespaces are consumed in the COMMAND state anyway. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index c2f577d71964..709b774f2404 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -88,12 +88,6 @@ n [A-Za-z0-9_-] return T_EOL; } [ \t]*#.* - - -[ \t]+ { - BEGIN(COMMAND); -} - . { unput(yytext[0]); BEGIN(COMMAND); From 21c5ecf60472be9f1b5bfe0b94870bef93db4202 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:48 +0900 Subject: [PATCH 11/39] kconfig: refactor pattern matching in STRING state Here, similar matching patters are duplicated in order to look ahead the '\n' character. If the next character is '\n', the lexer returns T_WORD_QUOTE because it must be prepared to return T_EOL at the next match. Use unput('\n') trick to reduce the code duplication. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 709b774f2404..b7bc164fdf00 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -182,19 +182,9 @@ n [A-Za-z0-9_-] { "$".* append_expanded_string(yytext); - [^$'"\\\n]+/\n { - append_string(yytext, yyleng); - yylval.string = text; - return T_WORD_QUOTE; - } [^$'"\\\n]+ { append_string(yytext, yyleng); } - \\.?/\n { - append_string(yytext + 1, yyleng - 1); - yylval.string = text; - return T_WORD_QUOTE; - } \\.? { append_string(yytext + 1, yyleng - 1); } @@ -210,8 +200,10 @@ n [A-Za-z0-9_-] fprintf(stderr, "%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno()); + unput('\n'); BEGIN(INITIAL); - return T_EOL; + yylval.string = text; + return T_WORD_QUOTE; } <> { BEGIN(INITIAL); From cc66bca775eeb81ef24456338bcd97e2e780c236 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:49 +0900 Subject: [PATCH 12/39] kconfig: fix ambiguous grammar in terms of new lines This commit decreases 8 shift/reduce conflicts. A certain amount of grammatical ambiguity comes from how to reduce excessive T_EOL tokens. Let's take a look at the example code below: 1 config A 2 bool "a" 3 4 depends on B 5 6 config B 7 def_bool y The line 3 is melt into "config_option_list", but the line 5 can be either a part of "config_option_list" or "common_stmt" by itself. Currently, the lexer converts '\n' to T_EOL verbatim. In Kconfig, a new line works as a statement terminator, but new lines in empty lines are not critical since empty lines (or lines that contain only whitespaces/comments) are just no-op. If the lexer simply discards no-op lines, the parser will not be bothered by excessive T_EOL tokens. Of course, this means we are shifting the complexity from the parser to the lexer, but it is much easier than tackling on shift/reduce conflicts. I introduced the second stage lexer to tweak the behavior. Discard T_EOL if the previous token is T_EOL or T_HELPTEXT. Two T_EOL tokens in a row is meaningless. T_HELPTEXT is a special token that is reduced without T_EOL. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 21 +++++++++++++++++++++ scripts/kconfig/zconf.y | 18 +++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index b7bc164fdf00..847ba4248092 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -16,6 +16,8 @@ #include "lkc.h" +#define YY_DECL static int yylex1(void) + #define START_STRSIZE 16 static struct { @@ -23,6 +25,7 @@ static struct { int lineno; } current_pos; +static int prev_token = T_EOL; static char *text; static int text_size, text_asize; @@ -268,6 +271,24 @@ n [A-Za-z0-9_-] } %% + +/* second stage lexer */ +int yylex(void) +{ + int token; + +repeat: + token = yylex1(); + + /* Do not pass unneeded T_EOL to the parser. */ + if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL) + goto repeat; + + prev_token = token; + + return token; +} + static char *expand_token(const char *in, size_t n) { char *out; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index c28f1a8f721d..02bfc62ba92c 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; %} -%expect 29 +%expect 21 %union { @@ -111,9 +111,7 @@ static struct menu *current_menu, *current_entry; %} %% -input: nl start | start; - -start: mainmenu_stmt stmt_list | stmt_list; +input: mainmenu_stmt stmt_list | stmt_list; /* mainmenu entry */ @@ -141,8 +139,7 @@ option_name: ; common_stmt: - T_EOL - | if_stmt + if_stmt | comment_stmt | config_stmt | menuconfig_stmt @@ -193,7 +190,6 @@ config_option_list: | config_option_list depends | config_option_list help | config_option_list option_error - | config_option_list T_EOL ; config_option: T_TYPE prompt_stmt_opt T_EOL @@ -293,7 +289,6 @@ choice_option_list: | choice_option_list choice_option | choice_option_list depends | choice_option_list help - | choice_option_list T_EOL | choice_option_list option_error ; @@ -443,7 +438,6 @@ help: help_start T_HELPTEXT depends_list: /* empty */ | depends_list depends - | depends_list T_EOL | depends_list option_error ; @@ -458,7 +452,6 @@ depends: T_DEPENDS T_ON expr T_EOL visibility_list: /* empty */ | visibility_list visible - | visibility_list T_EOL ; visible: T_VISIBLE if_expr T_EOL @@ -484,11 +477,6 @@ end: T_ENDMENU T_EOL { $$ = $1; } | T_ENDIF T_EOL { $$ = $1; } ; -nl: - T_EOL - | nl T_EOL -; - if_expr: /* empty */ { $$ = NULL; } | T_IF expr { $$ = $2; } ; From 0bcc547ec4b03a0b66615694561cce9c5a9a1014 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:50 +0900 Subject: [PATCH 13/39] kconfig: clean up EOF handling in the lexer A new file should always start in the INITIAL state. When the lexer bumps into EOF, the lexer must get back to the INITIAL state anyway. Remove the redundant <> pattern in the PARAM state. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 847ba4248092..9038e9736bf0 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -178,9 +178,6 @@ n [A-Za-z0-9_-] \\\n ; [[:blank:]]+ . warn_ignored_character(*yytext); - <> { - BEGIN(INITIAL); - } } { @@ -262,6 +259,8 @@ n [A-Za-z0-9_-] } <> { + BEGIN(INITIAL); + if (current_file) { zconf_endfile(); return T_EOL; From 723679339d087d79e36c0af67f4be84d866fee20 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:51 +0900 Subject: [PATCH 14/39] kconfig: warn no new line at end of file It would be nice to warn if a new line is missing at end of file. We could do this by checkpatch.pl for arbitrary files, but new line is rather essential as a statement terminator in Kconfig. The warning message looks like this: kernel/Kconfig.preempt:60:warning: no new line at end of file Currently, kernel/Kconfig.preempt is the only file with no new line at end of file. Fix it. I know there are some false negative cases. For example, no warning is displayed when the last line contains some whitespaces/comments, but no new line. Yet, this commit works well for most cases. Signed-off-by: Masahiro Yamada --- kernel/Kconfig.preempt | 2 +- scripts/kconfig/zconf.l | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/Kconfig.preempt b/kernel/Kconfig.preempt index cd1655122ec0..0fee5fe6c899 100644 --- a/kernel/Kconfig.preempt +++ b/kernel/Kconfig.preempt @@ -57,4 +57,4 @@ config PREEMPT endchoice config PREEMPT_COUNT - bool \ No newline at end of file + bool diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 9038e9736bf0..8e856f9e6da9 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -261,6 +261,10 @@ n [A-Za-z0-9_-] <> { BEGIN(INITIAL); + if (prev_token != T_EOL && prev_token != T_HELPTEXT) + fprintf(stderr, "%s:%d:warning: no new line at end of file\n", + current_file->name, yylineno); + if (current_file) { zconf_endfile(); return T_EOL; From 6900ae9eeee397436df25ef51835a8b27865d46d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:52 +0900 Subject: [PATCH 15/39] kconfig: remove grammatically ambiguous "unexpected option" diagnostic This commit decreases 15 shift/reduce conflicts. The location of this error recovery is ambiguous. For example, there are two ways to interpret the following code: 1 config FOO 2 bool "foo" [A] Both lines are reduced together into a config_stmt. [B] The only line 1 is reduced into a config_stmt, and the line 2 matches to "option_name error T_EOL" Of course, we expect [A], but [B] could be grammatically possible. Kconfig has no terminator for a config block. So, we cannot detect its end until we see a non-property keyword. People often insert a blank line between two config blocks, but it is just a coding convention. Blank lines are actually allowed anywhere in Kconfig files. The real error is when a property keyword appears right after "endif", "endchoice", "endmenu", "source", "comment", or variable assignment. Instead of fixing the grammatical ambiguity, I chose to simply remove this error recovery. The difference is unexpected option "bool" ... is turned into a more generic message: invalid statement Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 02bfc62ba92c..cef6123228c0 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; %} -%expect 21 +%expect 6 %union { @@ -94,7 +94,6 @@ static struct menu *current_menu, *current_entry; %type expr %type if_expr %type end -%type option_name %type if_entry menu_entry choice_entry %type symbol_option_arg word_opt assign_val @@ -127,17 +126,9 @@ stmt_list: | stmt_list menu_stmt | stmt_list end { zconf_error("unexpected end statement"); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } - | stmt_list option_name error T_EOL -{ - zconf_error("unexpected option \"%s\"", $2->name); -} | stmt_list error T_EOL { zconf_error("invalid statement"); } ; -option_name: - T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_IMPLY | T_OPTIONAL | T_RANGE | T_DEFAULT | T_VISIBLE -; - common_stmt: if_stmt | comment_stmt From 2f60e46e605a9bcd8dc4fe7745b5576084900850 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:53 +0900 Subject: [PATCH 16/39] kconfig: remove grammatically ambiguous option_error This commit decreases 6 shift/reduce conflicts, and finally achieves conflict-free parser. Since Kconfig has no terminator for a config block, detecting the end of config_stmt is not easy. For example, there are two ways for handling the error in the following code: 1 config FOO 2 = [A] Print "unknown option" error, assuming the line 2 is a part of config_option_list [B] Print "invalid statement", assuming the line 1 is reduced into a config_stmt by itself Bison actually chooses [A] because it performs the shift rather than the reduction where both are possible. However, there is no reason to choose one over the other. Let's remove the option_error, and let it fall back to [B]. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index cef6123228c0..a92f167e8267 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -31,7 +31,6 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; static struct menu *current_menu, *current_entry; %} -%expect 6 %union { @@ -138,12 +137,6 @@ common_stmt: | assignment_stmt ; -option_error: - T_WORD error T_EOL { zconf_error("unknown option \"%s\"", $1); } - | error T_EOL { zconf_error("invalid option"); } -; - - /* config/menuconfig entry */ config_entry_start: T_CONFIG nonconst_symbol T_EOL @@ -180,7 +173,6 @@ config_option_list: | config_option_list symbol_option | config_option_list depends | config_option_list help - | config_option_list option_error ; config_option: T_TYPE prompt_stmt_opt T_EOL @@ -280,7 +272,6 @@ choice_option_list: | choice_option_list choice_option | choice_option_list depends | choice_option_list help - | choice_option_list option_error ; choice_option: T_PROMPT prompt if_expr T_EOL @@ -429,7 +420,6 @@ help: help_start T_HELPTEXT depends_list: /* empty */ | depends_list depends - | depends_list option_error ; depends: T_DEPENDS T_ON expr T_EOL From 4891796c6f83bb3be5567b3053428a40329d7e37 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:54 +0900 Subject: [PATCH 17/39] kconfig: remove redundant if_block rule The code block surrounded by "if" ... "endif" is stmt_list. Remove the redundant if_block symbol entirely. Remove "stmt_list: stmt_list end" rule as well since it would obviously cause conflicts. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index a92f167e8267..dcbf6439ace9 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -123,7 +123,6 @@ stmt_list: | stmt_list common_stmt | stmt_list choice_stmt | stmt_list menu_stmt - | stmt_list end { zconf_error("unexpected end statement"); } | stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); } | stmt_list error T_EOL { zconf_error("invalid statement"); } ; @@ -330,14 +329,7 @@ if_end: end } }; -if_stmt: if_entry if_block if_end -; - -if_block: - /* empty */ - | if_block common_stmt - | if_block menu_stmt - | if_block choice_stmt +if_stmt: if_entry stmt_list if_end ; /* menu entry */ From 94d4e1b6021b8d63274c9961c70f95dd2b43e6fb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:55 +0900 Subject: [PATCH 18/39] kconfig: remove redundant menu_block rule The code block surrounded by "menu" ... "endmenu" is stmt_list. Remove the redundant menu_block symbol entirely. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index dcbf6439ace9..eeb449bd5869 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -354,14 +354,7 @@ menu_end: end } }; -menu_stmt: menu_entry menu_block menu_end -; - -menu_block: - /* empty */ - | menu_block common_stmt - | menu_block menu_stmt - | menu_block choice_stmt +menu_stmt: menu_entry stmt_list menu_end ; source_stmt: T_SOURCE prompt T_EOL From 1f31be9ec0a9d59053fb3d78591f6dd7a64a174e Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:56 +0900 Subject: [PATCH 19/39] kconfig: loosen the order of "visible" and "depends on" in menu entry Currently, "visible" and "depends on", if defined in a menu entry, must appear in that order. The real example is in drivers/media/tuners/Kconfig: menu "Customize TV tuners" visible if depends on ... is fine, but you cannot change the property order like this: menu "Customize TV tuners" depends on visible if Kconfig does not require a specific order of properties. In this case, menu_add_visibility(() and menu_add_dep() are orthogonal. Loosen this unreasonable restriction. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index eeb449bd5869..7cc824454e54 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -341,7 +341,7 @@ menu: T_MENU prompt T_EOL printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; -menu_entry: menu visibility_list depends_list +menu_entry: menu menu_option_list { $$ = menu_add_menu(); }; @@ -357,6 +357,12 @@ menu_end: end menu_stmt: menu_entry stmt_list menu_end ; +menu_option_list: + /* empty */ + | menu_option_list visible + | menu_option_list depends +; + source_stmt: T_SOURCE prompt T_EOL { printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); @@ -414,12 +420,6 @@ depends: T_DEPENDS T_ON expr T_EOL }; /* visibility option */ - -visibility_list: - /* empty */ - | visibility_list visible -; - visible: T_VISIBLE if_expr T_EOL { menu_add_visibility($2); From 4b5ec81bfeda09bda9cd8f545226c65291e4952b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:57 +0900 Subject: [PATCH 20/39] kconfig: rename depends_list to comment_option_list Now the comment_stmt is the only user of depends_list. Rename it to comment_option_list Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 7cc824454e54..7a4bc5826723 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -379,7 +379,12 @@ comment: T_COMMENT prompt T_EOL printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); }; -comment_stmt: comment depends_list +comment_stmt: comment comment_option_list +; + +comment_option_list: + /* empty */ + | comment_option_list depends ; /* help option */ @@ -408,11 +413,6 @@ help: help_start T_HELPTEXT /* depends option */ -depends_list: - /* empty */ - | depends_list depends -; - depends: T_DEPENDS T_ON expr T_EOL { menu_add_dep($3); From a01e5d242d932f67f2657ceb0d76be777cd05a04 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:58 +0900 Subject: [PATCH 21/39] kconfig: remove redundant token defines These are already defined as %left. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 7a4bc5826723..020454bcdf94 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -69,11 +69,6 @@ static struct menu *current_menu, *current_entry; %token T_ON %token T_WORD %token T_WORD_QUOTE -%token T_UNEQUAL -%token T_LESS -%token T_LESS_EQUAL -%token T_GREATER -%token T_GREATER_EQUAL %token T_CLOSE_PAREN %token T_OPEN_PAREN %token T_EOL From 3c8f317d4cf15e7a67457cfdd1e63182a34bcb69 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:00:59 +0900 Subject: [PATCH 22/39] kconfig: use distinct tokens for type and default properties This commit removes kconf_id::stype to prepare for the entire removal of kconf_id.c To simplify the lexer, I want keywords straight-mapped to tokens. Signed-off-by: Masahiro Yamada --- scripts/kconfig/kconf_id.c | 16 +++++----- scripts/kconfig/lkc.h | 1 - scripts/kconfig/zconf.y | 62 ++++++++++++++++++++++++-------------- 3 files changed, 47 insertions(+), 32 deletions(-) diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c index b3e0ea0ac732..ec2c011f9e62 100644 --- a/scripts/kconfig/kconf_id.c +++ b/scripts/kconfig/kconf_id.c @@ -15,15 +15,15 @@ static struct kconf_id kconf_id_array[] = { { "endif", T_ENDIF, TF_COMMAND }, { "depends", T_DEPENDS, TF_COMMAND }, { "optional", T_OPTIONAL, TF_COMMAND }, - { "default", T_DEFAULT, TF_COMMAND, S_UNKNOWN }, + { "default", T_DEFAULT, TF_COMMAND }, + { "def_bool", T_DEF_BOOL, TF_COMMAND }, + { "def_tristate", T_DEF_TRISTATE, TF_COMMAND }, { "prompt", T_PROMPT, TF_COMMAND }, - { "tristate", T_TYPE, TF_COMMAND, S_TRISTATE }, - { "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE }, - { "bool", T_TYPE, TF_COMMAND, S_BOOLEAN }, - { "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN }, - { "int", T_TYPE, TF_COMMAND, S_INT }, - { "hex", T_TYPE, TF_COMMAND, S_HEX }, - { "string", T_TYPE, TF_COMMAND, S_STRING }, + { "bool", T_BOOL, TF_COMMAND }, + { "tristate", T_TRISTATE, TF_COMMAND }, + { "int", T_INT, TF_COMMAND }, + { "hex", T_HEX, TF_COMMAND }, + { "string", T_STRING, TF_COMMAND }, { "select", T_SELECT, TF_COMMAND }, { "imply", T_IMPLY, TF_COMMAND }, { "range", T_RANGE, TF_COMMAND }, diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 9eb7c837cd8f..b6bbcd1dda2b 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -50,7 +50,6 @@ struct kconf_id { const char *name; int token; unsigned int flags; - enum symbol_type stype; }; extern int yylineno; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 020454bcdf94..19fa333e9aa1 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -40,6 +40,7 @@ static struct menu *current_menu, *current_entry; struct expr *expr; struct menu *menu; const struct kconf_id *id; + enum symbol_type type; enum variable_flavor flavor; } @@ -59,8 +60,6 @@ static struct menu *current_menu, *current_entry; %token T_DEPENDS %token T_OPTIONAL %token T_PROMPT -%token T_TYPE -%token T_DEFAULT %token T_SELECT %token T_IMPLY %token T_RANGE @@ -69,8 +68,16 @@ static struct menu *current_menu, *current_entry; %token T_ON %token T_WORD %token T_WORD_QUOTE +%token T_BOOL %token T_CLOSE_PAREN +%token T_DEFAULT +%token T_DEF_BOOL +%token T_DEF_TRISTATE +%token T_HEX +%token T_INT %token T_OPEN_PAREN +%token T_STRING +%token T_TRISTATE %token T_EOL %token T_VARIABLE %token T_ASSIGN @@ -85,6 +92,7 @@ static struct menu *current_menu, *current_entry; %type prompt %type nonconst_symbol %type symbol +%type type logic_type default %type expr %type if_expr %type end @@ -169,12 +177,12 @@ config_option_list: | config_option_list help ; -config_option: T_TYPE prompt_stmt_opt T_EOL +config_option: type prompt_stmt_opt T_EOL { - menu_set_type($1->stype); + menu_set_type($1); printd(DEBUG_PARSE, "%s:%d:type(%u)\n", zconf_curname(), zconf_lineno(), - $1->stype); + $1); }; config_option: T_PROMPT prompt if_expr T_EOL @@ -183,14 +191,14 @@ config_option: T_PROMPT prompt if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; -config_option: T_DEFAULT expr if_expr T_EOL +config_option: default expr if_expr T_EOL { menu_add_expr(P_DEFAULT, $2, $3); - if ($1->stype != S_UNKNOWN) - menu_set_type($1->stype); + if ($1 != S_UNKNOWN) + menu_set_type($1); printd(DEBUG_PARSE, "%s:%d:default(%u)\n", zconf_curname(), zconf_lineno(), - $1->stype); + $1); }; config_option: T_SELECT nonconst_symbol if_expr T_EOL @@ -274,15 +282,11 @@ choice_option: T_PROMPT prompt if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; -choice_option: T_TYPE prompt_stmt_opt T_EOL +choice_option: logic_type prompt_stmt_opt T_EOL { - if ($1->stype == S_BOOLEAN || $1->stype == S_TRISTATE) { - menu_set_type($1->stype); - printd(DEBUG_PARSE, "%s:%d:type(%u)\n", - zconf_curname(), zconf_lineno(), - $1->stype); - } else - YYERROR; + menu_set_type($1); + printd(DEBUG_PARSE, "%s:%d:type(%u)\n", + zconf_curname(), zconf_lineno(), $1); }; choice_option: T_OPTIONAL T_EOL @@ -293,14 +297,26 @@ choice_option: T_OPTIONAL T_EOL choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL { - if ($1->stype == S_UNKNOWN) { - menu_add_symbol(P_DEFAULT, $2, $3); - printd(DEBUG_PARSE, "%s:%d:default\n", - zconf_curname(), zconf_lineno()); - } else - YYERROR; + menu_add_symbol(P_DEFAULT, $2, $3); + printd(DEBUG_PARSE, "%s:%d:default\n", + zconf_curname(), zconf_lineno()); }; +type: + logic_type + | T_INT { $$ = S_INT; } + | T_HEX { $$ = S_HEX; } + | T_STRING { $$ = S_STRING; } + +logic_type: + T_BOOL { $$ = S_BOOLEAN; } + | T_TRISTATE { $$ = S_TRISTATE; } + +default: + T_DEFAULT { $$ = S_UNKNOWN; } + | T_DEF_BOOL { $$ = S_BOOLEAN; } + | T_DEF_TRISTATE { $$ = S_TRISTATE; } + choice_block: /* empty */ | choice_block common_stmt From ce2164ab58316e27180034112f97608a764f5b37 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:00 +0900 Subject: [PATCH 23/39] kconfig: refactor scanning and parsing "option" properties For the keywords "modules", "defconfig_list", and "allnoconfig_y", the lexer should pass specific tokens instead of generic T_WORD. This simplifies both the lexer and the parser. Signed-off-by: Masahiro Yamada --- scripts/kconfig/kconf_id.c | 3 --- scripts/kconfig/lkc.h | 9 +++------ scripts/kconfig/menu.c | 41 ++++++++++++++++++-------------------- scripts/kconfig/zconf.l | 3 +++ scripts/kconfig/zconf.y | 37 +++++++++++++++------------------- 5 files changed, 41 insertions(+), 52 deletions(-) diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c index ec2c011f9e62..f8b222cc8b87 100644 --- a/scripts/kconfig/kconf_id.c +++ b/scripts/kconfig/kconf_id.c @@ -30,9 +30,6 @@ static struct kconf_id kconf_id_array[] = { { "visible", T_VISIBLE, TF_COMMAND }, { "option", T_OPTION, TF_COMMAND }, { "on", T_ON, TF_PARAM }, - { "modules", T_OPT_MODULES, TF_OPTION }, - { "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION }, - { "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION }, }; #define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id)) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index b6bbcd1dda2b..5f4880a12246 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -32,7 +32,6 @@ static inline const char *CONFIG_prefix(void) #define TF_COMMAND 0x0001 #define TF_PARAM 0x0002 -#define TF_OPTION 0x0004 enum conf_def_mode { def_default, @@ -42,10 +41,6 @@ enum conf_def_mode { def_random }; -#define T_OPT_MODULES 1 -#define T_OPT_DEFCONFIG_LIST 2 -#define T_OPT_ALLNOCONFIG_Y 4 - struct kconf_id { const char *name; int token; @@ -90,7 +85,9 @@ void menu_add_visibility(struct expr *dep); struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); -void menu_add_option(int token, char *arg); +void menu_add_option_modules(void); +void menu_add_option_defconfig_list(void); +void menu_add_option_allnoconfig_y(void); void menu_finalize(struct menu *parent); void menu_set_type(int type); diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 4cf15d449c05..7e2b2c938d7b 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -195,29 +195,26 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep) menu_add_prop(type, NULL, expr_alloc_symbol(sym), dep); } -void menu_add_option(int token, char *arg) +void menu_add_option_modules(void) { - switch (token) { - case T_OPT_MODULES: - if (modules_sym) - zconf_error("symbol '%s' redefines option 'modules'" - " already defined by symbol '%s'", - current_entry->sym->name, - modules_sym->name - ); - modules_sym = current_entry->sym; - break; - case T_OPT_DEFCONFIG_LIST: - if (!sym_defconfig_list) - sym_defconfig_list = current_entry->sym; - else if (sym_defconfig_list != current_entry->sym) - zconf_error("trying to redefine defconfig symbol"); - sym_defconfig_list->flags |= SYMBOL_NO_WRITE; - break; - case T_OPT_ALLNOCONFIG_Y: - current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; - break; - } + if (modules_sym) + zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'", + current_entry->sym->name, modules_sym->name); + modules_sym = current_entry->sym; +} + +void menu_add_option_defconfig_list(void) +{ + if (!sym_defconfig_list) + sym_defconfig_list = current_entry->sym; + else if (sym_defconfig_list != current_entry->sym) + zconf_error("trying to redefine defconfig symbol"); + sym_defconfig_list->flags |= SYMBOL_NO_WRITE; +} + +void menu_add_option_allnoconfig_y(void) +{ + current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y; } static int menu_validate_number(struct symbol *sym, struct symbol *sym2) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 8e856f9e6da9..30380790bab4 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -140,6 +140,9 @@ n [A-Za-z0-9_-] } { + "modules" return T_MODULES; + "defconfig_list" return T_DEFCONFIG_LIST; + "allnoconfig_y" return T_ALLNOCONFIG_Y; "&&" return T_AND; "||" return T_OR; "(" return T_OPEN_PAREN; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 19fa333e9aa1..e482000bb93e 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -64,18 +64,21 @@ static struct menu *current_menu, *current_entry; %token T_IMPLY %token T_RANGE %token T_VISIBLE -%token T_OPTION %token T_ON %token T_WORD %token T_WORD_QUOTE +%token T_ALLNOCONFIG_Y %token T_BOOL %token T_CLOSE_PAREN %token T_DEFAULT +%token T_DEFCONFIG_LIST %token T_DEF_BOOL %token T_DEF_TRISTATE %token T_HEX %token T_INT +%token T_MODULES %token T_OPEN_PAREN +%token T_OPTION %token T_STRING %token T_TRISTATE %token T_EOL @@ -97,7 +100,7 @@ static struct menu *current_menu, *current_entry; %type if_expr %type end %type if_entry menu_entry choice_entry -%type symbol_option_arg word_opt assign_val +%type word_opt assign_val %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -172,7 +175,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list config_option_list: /* empty */ | config_option_list config_option - | config_option_list symbol_option | config_option_list depends | config_option_list help ; @@ -219,27 +221,20 @@ config_option: T_RANGE symbol symbol if_expr T_EOL printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); }; -symbol_option: T_OPTION symbol_option_list T_EOL -; - -symbol_option_list: - /* empty */ - | symbol_option_list T_WORD symbol_option_arg +config_option: T_OPTION T_MODULES T_EOL { - const struct kconf_id *id = kconf_id_lookup($2, strlen($2)); - if (id && id->flags & TF_OPTION) { - menu_add_option(id->token, $3); - free($3); - } - else - zconfprint("warning: ignoring unknown option %s", $2); - free($2); + menu_add_option_modules(); }; -symbol_option_arg: - /* empty */ { $$ = NULL; } - | T_EQUAL prompt { $$ = $2; } -; +config_option: T_OPTION T_DEFCONFIG_LIST T_EOL +{ + menu_add_option_defconfig_list(); +}; + +config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL +{ + menu_add_option_allnoconfig_y(); +}; /* choice entry */ From c3d228713b10e6dd1bd44853168cec8e23ae7e0f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:01 +0900 Subject: [PATCH 24/39] kconfig: use specific tokens instead of T_ASSIGN for assignments Currently, the lexer returns T_ASSIGN for all of =, :=, and += associating yylval with the flavor. I want to make the generated lexer as simple as possible. So, the lexer should convert keywords to tokens without thinking about the meaning. = -> T_EQUAL := -> T_COLON_EQUAL += -> T_PLUS_EQUAL Unfortunately, Kconfig uses = instead of == for the equal operator. So, the same token T_EQUAL is used for assignment and comparison. The parser can still distinguish them from the context. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 6 +++--- scripts/kconfig/zconf.y | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 30380790bab4..b1a71f612c11 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -118,9 +118,9 @@ n [A-Za-z0-9_-] return T_VARIABLE; free(yylval.string); } - "=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_RECURSIVE; return T_ASSIGN; } - ":=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_SIMPLE; return T_ASSIGN; } - "+=" { BEGIN(ASSIGN_VAL); yylval.flavor = VAR_APPEND; return T_ASSIGN; } + "=" { BEGIN(ASSIGN_VAL); return T_EQUAL; } + ":=" { BEGIN(ASSIGN_VAL); return T_COLON_EQUAL; } + "+=" { BEGIN(ASSIGN_VAL); return T_PLUS_EQUAL; } [[:blank:]]+ . warn_ignored_character(*yytext); \n { diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index e482000bb93e..3b7ebd363e7e 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -70,6 +70,7 @@ static struct menu *current_menu, *current_entry; %token T_ALLNOCONFIG_Y %token T_BOOL %token T_CLOSE_PAREN +%token T_COLON_EQUAL %token T_DEFAULT %token T_DEFCONFIG_LIST %token T_DEF_BOOL @@ -79,11 +80,11 @@ static struct menu *current_menu, *current_entry; %token T_MODULES %token T_OPEN_PAREN %token T_OPTION +%token T_PLUS_EQUAL %token T_STRING %token T_TRISTATE %token T_EOL %token T_VARIABLE -%token T_ASSIGN %token T_ASSIGN_VAL %left T_OR @@ -101,6 +102,7 @@ static struct menu *current_menu, *current_entry; %type end %type if_entry menu_entry choice_entry %type word_opt assign_val +%type assign_op %destructor { fprintf(stderr, "%s:%d: missing end statement for this entry\n", @@ -478,7 +480,13 @@ word_opt: /* empty */ { $$ = NULL; } /* assignment statement */ -assignment_stmt: T_VARIABLE T_ASSIGN assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } +assignment_stmt: T_VARIABLE assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } + +assign_op: + T_EQUAL { $$ = VAR_RECURSIVE; } + | T_COLON_EQUAL { $$ = VAR_SIMPLE; } + | T_PLUS_EQUAL { $$ = VAR_APPEND; } +; assign_val: /* empty */ { $$ = xstrdup(""); }; From 171a515d080327b861d5e5fc9bbfa77f10cfddd7 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:02 +0900 Subject: [PATCH 25/39] kconfig: use T_WORD instead of T_VARIABLE for variables There is no grammatical ambiguity by using T_WORD for variables. The parser can distinguish variables from symbols from the context. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 4 ++-- scripts/kconfig/zconf.y | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index b1a71f612c11..f8bd84714e00 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -109,13 +109,13 @@ n [A-Za-z0-9_-] } alloc_string(yytext, yyleng); yylval.string = text; - return T_VARIABLE; + return T_WORD; } ({n}|$)+ { /* this token includes at least one '$' */ yylval.string = expand_token(yytext, yyleng); if (strlen(yylval.string)) - return T_VARIABLE; + return T_WORD; free(yylval.string); } "=" { BEGIN(ASSIGN_VAL); return T_EQUAL; } diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 3b7ebd363e7e..2127f1d65170 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -84,7 +84,6 @@ static struct menu *current_menu, *current_entry; %token T_STRING %token T_TRISTATE %token T_EOL -%token T_VARIABLE %token T_ASSIGN_VAL %left T_OR @@ -480,7 +479,7 @@ word_opt: /* empty */ { $$ = NULL; } /* assignment statement */ -assignment_stmt: T_VARIABLE assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } +assignment_stmt: T_WORD assign_op assign_val T_EOL { variable_add($1, $3, $2); free($1); free($3); } assign_op: T_EQUAL { $$ = VAR_RECURSIVE; } From 48547bd23d0eeb2cf3a63ed588b46236eac5f2c3 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:03 +0900 Subject: [PATCH 26/39] microblaze: surround string default in Kconfig with double quotes I guess this is a constant value instead of a symbol. Signed-off-by: Masahiro Yamada Acked-by: Michal Simek --- arch/microblaze/Kconfig.platform | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/microblaze/Kconfig.platform b/arch/microblaze/Kconfig.platform index f7f1739c11b9..7361974417dc 100644 --- a/arch/microblaze/Kconfig.platform +++ b/arch/microblaze/Kconfig.platform @@ -65,6 +65,6 @@ config XILINX_MICROBLAZE0_USE_FPU config XILINX_MICROBLAZE0_HW_VER string "Core version number" - default 7.10.d + default "7.10.d" endmenu From 8636a1f9677db4f883f29a072f401303acfc2edd Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:04 +0900 Subject: [PATCH 27/39] treewide: surround Kconfig file paths with double quotes The Kconfig lexer supports special characters such as '.' and '/' in the parameter context. In my understanding, the reason is just to support bare file paths in the source statement. I do not see a good reason to complicate Kconfig for the room of ambiguity. The majority of code already surrounds file paths with double quotes, and it makes sense since file paths are constant string literals. Make it treewide consistent now. Signed-off-by: Masahiro Yamada Acked-by: Wolfram Sang Acked-by: Geert Uytterhoeven Acked-by: Ingo Molnar --- arch/arm/Kconfig | 2 +- arch/arm/kvm/Kconfig | 2 +- arch/arm64/Kconfig | 2 +- arch/arm64/kvm/Kconfig | 2 +- arch/ia64/Kconfig | 2 +- arch/m68k/Kconfig | 6 +++--- arch/mips/kvm/Kconfig | 2 +- arch/openrisc/Kconfig | 2 +- arch/powerpc/Kconfig | 4 ++-- arch/powerpc/kvm/Kconfig | 2 +- arch/riscv/Kconfig | 2 +- arch/s390/Kconfig | 2 +- arch/s390/kvm/Kconfig | 2 +- arch/sh/Kconfig | 2 +- arch/sparc/Kconfig | 2 +- arch/x86/Kconfig | 2 +- arch/x86/kvm/Kconfig | 2 +- block/Kconfig | 2 +- crypto/Kconfig | 4 ++-- drivers/crypto/Kconfig | 2 +- drivers/gpu/drm/i915/Kconfig | 2 +- drivers/hwmon/Kconfig | 2 +- drivers/i2c/Kconfig | 6 +++--- drivers/pps/Kconfig | 4 ++-- drivers/ras/Kconfig | 2 +- drivers/thermal/Kconfig | 2 +- drivers/w1/Kconfig | 4 ++-- lib/Kconfig.debug | 4 ++-- security/Kconfig | 16 ++++++++-------- security/integrity/Kconfig | 4 ++-- 30 files changed, 47 insertions(+), 47 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 91be74d8df65..0a7faf82250e 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -910,7 +910,7 @@ config PLAT_VERSATILE source "arch/arm/firmware/Kconfig" -source arch/arm/mm/Kconfig +source "arch/arm/mm/Kconfig" config IWMMXT bool "Enable iWMMXt support" diff --git a/arch/arm/kvm/Kconfig b/arch/arm/kvm/Kconfig index e2bd35b6780c..3f5320f46de2 100644 --- a/arch/arm/kvm/Kconfig +++ b/arch/arm/kvm/Kconfig @@ -55,6 +55,6 @@ config KVM_ARM_HOST ---help--- Provides host support for ARM processors. -source drivers/vhost/Kconfig +source "drivers/vhost/Kconfig" endif # VIRTUALIZATION diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 787d7850e064..04e525fc5a0f 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -782,7 +782,7 @@ config NEED_PER_CPU_EMBED_FIRST_CHUNK config HOLES_IN_ZONE def_bool y -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config ARCH_SUPPORTS_DEBUG_PAGEALLOC def_bool y diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig index 47b23bf617c7..a3f85624313e 100644 --- a/arch/arm64/kvm/Kconfig +++ b/arch/arm64/kvm/Kconfig @@ -61,6 +61,6 @@ config KVM_ARM_PMU config KVM_INDIRECT_VECTORS def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS) -source drivers/vhost/Kconfig +source "drivers/vhost/Kconfig" endif # VIRTUALIZATION diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig index 36773def6920..0ef105ac40f6 100644 --- a/arch/ia64/Kconfig +++ b/arch/ia64/Kconfig @@ -261,7 +261,7 @@ config HZ endif if !IA64_HP_SIM -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" endif config IA64_BRL_EMU diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig index 1bc9f1ba759a..6f18c45f7703 100644 --- a/arch/m68k/Kconfig +++ b/arch/m68k/Kconfig @@ -123,11 +123,11 @@ config BOOTINFO_PROC menu "Platform setup" -source arch/m68k/Kconfig.cpu +source "arch/m68k/Kconfig.cpu" -source arch/m68k/Kconfig.machine +source "arch/m68k/Kconfig.machine" -source arch/m68k/Kconfig.bus +source "arch/m68k/Kconfig.bus" endmenu diff --git a/arch/mips/kvm/Kconfig b/arch/mips/kvm/Kconfig index 76b93a9c8c9b..c36930226b7b 100644 --- a/arch/mips/kvm/Kconfig +++ b/arch/mips/kvm/Kconfig @@ -72,6 +72,6 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS If unsure, say N. -source drivers/vhost/Kconfig +source "drivers/vhost/Kconfig" endif # VIRTUALIZATION diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index 285f7d05c8ed..d765b4a5e05f 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig @@ -139,7 +139,7 @@ config SMP If you don't know what to do here, say N. -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config OPENRISC_NO_SPR_SR_DSX bool "use SPR_SR_DSX software emulation" if OR1K_1200 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index 8be31261aec8..e1307d66c76b 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -393,7 +393,7 @@ config HIGHMEM bool "High memory support" depends on PPC32 -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config HUGETLB_PAGE_SIZE_VARIABLE bool @@ -816,7 +816,7 @@ config ARCH_WANTS_FREEZER_CONTROL def_bool y depends on ADB_PMU -source kernel/power/Kconfig +source "kernel/power/Kconfig" config SECCOMP bool "Enable seccomp to safely compute untrusted bytecode" diff --git a/arch/powerpc/kvm/Kconfig b/arch/powerpc/kvm/Kconfig index 68a0e9d5b440..bfdde04e4905 100644 --- a/arch/powerpc/kvm/Kconfig +++ b/arch/powerpc/kvm/Kconfig @@ -204,6 +204,6 @@ config KVM_XIVE default y depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE -source drivers/vhost/Kconfig +source "drivers/vhost/Kconfig" endif # VIRTUALIZATION diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 55da93f4e818..4f428ab4429f 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -287,6 +287,6 @@ endmenu menu "Power management options" -source kernel/power/Kconfig +source "kernel/power/Kconfig" endmenu diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 5173366af8f3..48de9d32b833 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -520,7 +520,7 @@ config SCHED_TOPOLOGY making when dealing with machines that have multi-threading, multiple cores or multiple books. -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config KEXEC def_bool y diff --git a/arch/s390/kvm/Kconfig b/arch/s390/kvm/Kconfig index a3dbd459cce9..767453faacfc 100644 --- a/arch/s390/kvm/Kconfig +++ b/arch/s390/kvm/Kconfig @@ -57,6 +57,6 @@ config KVM_S390_UCONTROL # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. -source drivers/vhost/Kconfig +source "drivers/vhost/Kconfig" endif # VIRTUALIZATION diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index f82a4da7adf3..b2581b14e464 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -597,7 +597,7 @@ endmenu menu "Kernel features" -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config KEXEC bool "kexec system call (EXPERIMENTAL)" diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 490b2c95c212..29b97f1dd9c5 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -187,7 +187,7 @@ config NR_CPUS default 32 if SPARC32 default 4096 if SPARC64 -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config RWSEM_GENERIC_SPINLOCK bool diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 9d734f3c8234..fd5ac1d89d74 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1975,7 +1975,7 @@ config SECCOMP If unsure, say Y. Only embedded should say N here. -source kernel/Kconfig.hz +source "kernel/Kconfig.hz" config KEXEC bool "kexec system call" diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 1bbec387d289..72fa955f4a15 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -98,6 +98,6 @@ config KVM_MMU_AUDIT # OK, it's a little counter-intuitive to do this, but it puts it neatly under # the virtualization menu. -source drivers/vhost/Kconfig +source "drivers/vhost/Kconfig" endif # VIRTUALIZATION diff --git a/block/Kconfig b/block/Kconfig index f7045aa47edb..1b9149810999 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -224,4 +224,4 @@ config BLK_MQ_RDMA config BLK_PM def_bool BLOCK && PM -source block/Kconfig.iosched +source "block/Kconfig.iosched" diff --git a/crypto/Kconfig b/crypto/Kconfig index f7a235db56aa..2c63b52a5fcc 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -1826,7 +1826,7 @@ config CRYPTO_HASH_INFO bool source "drivers/crypto/Kconfig" -source crypto/asymmetric_keys/Kconfig -source certs/Kconfig +source "crypto/asymmetric_keys/Kconfig" +source "certs/Kconfig" endif # if CRYPTO diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index caa98a7fe392..4db49de39b3e 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -258,7 +258,7 @@ config CRYPTO_DEV_HIFN_795X_RNG Select this option if you want to enable the random number generator on the HIFN 795x crypto adapters. -source drivers/crypto/caam/Kconfig +source "drivers/crypto/caam/Kconfig" config CRYPTO_DEV_TALITOS tristate "Talitos Freescale Security Engine (SEC)" diff --git a/drivers/gpu/drm/i915/Kconfig b/drivers/gpu/drm/i915/Kconfig index 33a458b7f1fc..148be8e1a090 100644 --- a/drivers/gpu/drm/i915/Kconfig +++ b/drivers/gpu/drm/i915/Kconfig @@ -131,5 +131,5 @@ config DRM_I915_GVT_KVMGT menu "drm/i915 Debugging" depends on DRM_I915 depends on EXPERT -source drivers/gpu/drm/i915/Kconfig.debug +source "drivers/gpu/drm/i915/Kconfig.debug" endmenu diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 81da17a42dc9..9ccbbd39b3c6 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1306,7 +1306,7 @@ config SENSORS_PCF8591 These devices are hard to detect and rarely found on mainstream hardware. If unsure, say N. -source drivers/hwmon/pmbus/Kconfig +source "drivers/hwmon/pmbus/Kconfig" config SENSORS_PWM_FAN tristate "PWM fan" diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig index efc3354d60ae..c6b7fc7b67d6 100644 --- a/drivers/i2c/Kconfig +++ b/drivers/i2c/Kconfig @@ -68,7 +68,7 @@ config I2C_MUX This support is also available as a module. If so, the module will be called i2c-mux. -source drivers/i2c/muxes/Kconfig +source "drivers/i2c/muxes/Kconfig" config I2C_HELPER_AUTO bool "Autoselect pertinent helper modules" @@ -94,8 +94,8 @@ config I2C_SMBUS This support is also available as a module. If so, the module will be called i2c-smbus. -source drivers/i2c/algos/Kconfig -source drivers/i2c/busses/Kconfig +source "drivers/i2c/algos/Kconfig" +source "drivers/i2c/busses/Kconfig" config I2C_STUB tristate "I2C/SMBus Test Stub" diff --git a/drivers/pps/Kconfig b/drivers/pps/Kconfig index c6008f296605..965aa086a1e0 100644 --- a/drivers/pps/Kconfig +++ b/drivers/pps/Kconfig @@ -37,8 +37,8 @@ config NTP_PPS It doesn't work on tickless systems at the moment. -source drivers/pps/clients/Kconfig +source "drivers/pps/clients/Kconfig" -source drivers/pps/generators/Kconfig +source "drivers/pps/generators/Kconfig" endif # PPS diff --git a/drivers/ras/Kconfig b/drivers/ras/Kconfig index 4c3c67d13254..b834ff555188 100644 --- a/drivers/ras/Kconfig +++ b/drivers/ras/Kconfig @@ -30,6 +30,6 @@ menuconfig RAS if RAS -source arch/x86/ras/Kconfig +source "arch/x86/ras/Kconfig" endif diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index 5422523c03f8..5fbfabbf627b 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -383,7 +383,7 @@ config INTEL_QUARK_DTS_THERMAL underlying BIOS/Firmware. menu "ACPI INT340X thermal drivers" -source drivers/thermal/int340x_thermal/Kconfig +source "drivers/thermal/int340x_thermal/Kconfig" endmenu config INTEL_BXT_PMIC_THERMAL diff --git a/drivers/w1/Kconfig b/drivers/w1/Kconfig index 6743bde038cc..dbb41f45af8a 100644 --- a/drivers/w1/Kconfig +++ b/drivers/w1/Kconfig @@ -25,7 +25,7 @@ config W1_CON 2. Userspace commands. Includes read/write and search/alarm search commands. 3. Replies to userspace commands. -source drivers/w1/masters/Kconfig -source drivers/w1/slaves/Kconfig +source "drivers/w1/masters/Kconfig" +source "drivers/w1/slaves/Kconfig" endif # W1 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 1af29b8224fd..08a95da1adcc 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -439,7 +439,7 @@ config DEBUG_KERNEL menu "Memory Debugging" -source mm/Kconfig.debug +source "mm/Kconfig.debug" config DEBUG_OBJECTS bool "Debug object operations" @@ -1609,7 +1609,7 @@ config LATENCYTOP Enable this option if you want to use the LatencyTOP tool to find out which userspace is blocking on what kernel operations. -source kernel/trace/Kconfig +source "kernel/trace/Kconfig" config PROVIDE_OHCI1394_DMA_INIT bool "Remote debugging over FireWire early on boot" diff --git a/security/Kconfig b/security/Kconfig index d9aa521b5206..e4fe2f3c2c65 100644 --- a/security/Kconfig +++ b/security/Kconfig @@ -4,7 +4,7 @@ menu "Security options" -source security/keys/Kconfig +source "security/keys/Kconfig" config SECURITY_DMESG_RESTRICT bool "Restrict unprivileged access to the kernel syslog" @@ -230,14 +230,14 @@ config STATIC_USERMODEHELPER_PATH If you wish for all usermode helper programs to be disabled, specify an empty string here (i.e. ""). -source security/selinux/Kconfig -source security/smack/Kconfig -source security/tomoyo/Kconfig -source security/apparmor/Kconfig -source security/loadpin/Kconfig -source security/yama/Kconfig +source "security/selinux/Kconfig" +source "security/smack/Kconfig" +source "security/tomoyo/Kconfig" +source "security/apparmor/Kconfig" +source "security/loadpin/Kconfig" +source "security/yama/Kconfig" -source security/integrity/Kconfig +source "security/integrity/Kconfig" choice prompt "Default security module" diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig index da9565891738..877af1f2d904 100644 --- a/security/integrity/Kconfig +++ b/security/integrity/Kconfig @@ -66,7 +66,7 @@ config INTEGRITY_AUDIT be enabled by specifying 'integrity_audit=1' on the kernel command line. -source security/integrity/ima/Kconfig -source security/integrity/evm/Kconfig +source "security/integrity/ima/Kconfig" +source "security/integrity/evm/Kconfig" endif # if INTEGRITY From f5451582c4e22ce8912aae4950810f3598c9b516 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:05 +0900 Subject: [PATCH 28/39] kconfig: stop supporting '.' and '/' in unquoted words In my understanding, special characters such as '.' and '/' are supported in unquoted words to use bare file paths in the "source" statement. With the previous commit surrounding all file paths with double quotes, we can drop this. Signed-off-by: Masahiro Yamada --- scripts/kconfig/preprocess.c | 3 +-- scripts/kconfig/zconf.l | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index 5ca2df790d3c..b028a48b0e76 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -555,8 +555,7 @@ char *expand_string(const char *in) static bool is_end_of_token(char c) { - /* Why are '.' and '/' valid characters for symbols? */ - return !(isalnum(c) || c == '_' || c == '-' || c == '.' || c == '/'); + return !(isalnum(c) || c == '_' || c == '-'); } /* diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index f8bd84714e00..90d2f37159dc 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -160,7 +160,7 @@ n [A-Za-z0-9_-] BEGIN(STRING); } \n BEGIN(INITIAL); return T_EOL; - ({n}|[/.])+ { + {n}+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { yylval.id = id; @@ -170,7 +170,7 @@ n [A-Za-z0-9_-] yylval.string = text; return T_WORD; } - ({n}|[/.$])+ { + ({n}|$)+ { /* this token includes at least one '$' */ yylval.string = expand_token(yytext, yyleng); if (strlen(yylval.string)) From caaebb3c6de3493c7f11f79a5dddc6691a40e55f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:06 +0900 Subject: [PATCH 29/39] kconfig: refactor end token rules T_ENDMENU, T_ENDCHOICE, T_ENDIF are the last users of kconf_id associated with yylval. Refactor them to not use it. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.y | 43 ++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 2127f1d65170..71c2fe737e37 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -24,7 +24,8 @@ int yylex(void); static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); -static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken); +static bool zconf_endtoken(const char *tokenname, + const char *expected_tokenname); struct symbol *symbol_hash[SYMBOL_HASHSIZE]; @@ -98,7 +99,7 @@ static struct menu *current_menu, *current_entry; %type type logic_type default %type expr %type if_expr -%type end +%type end %type if_entry menu_entry choice_entry %type word_opt assign_val %type assign_op @@ -256,7 +257,7 @@ choice_entry: choice choice_option_list choice_end: end { - if (zconf_endtoken($1, T_CHOICE, T_ENDCHOICE)) { + if (zconf_endtoken($1, "choice")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); } @@ -330,7 +331,7 @@ if_entry: T_IF expr T_EOL if_end: end { - if (zconf_endtoken($1, T_IF, T_ENDIF)) { + if (zconf_endtoken($1, "if")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); } @@ -355,7 +356,7 @@ menu_entry: menu menu_option_list menu_end: end { - if (zconf_endtoken($1, T_MENU, T_ENDMENU)) { + if (zconf_endtoken($1, "menu")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); } @@ -445,9 +446,9 @@ prompt: T_WORD | T_WORD_QUOTE ; -end: T_ENDMENU T_EOL { $$ = $1; } - | T_ENDCHOICE T_EOL { $$ = $1; } - | T_ENDIF T_EOL { $$ = $1; } +end: T_ENDMENU T_EOL { $$ = "menu"; } + | T_ENDCHOICE T_EOL { $$ = "choice"; } + | T_ENDIF T_EOL { $$ = "if"; } ; if_expr: /* empty */ { $$ = NULL; } @@ -530,35 +531,21 @@ void conf_parse(const char *name) sym_set_change_count(1); } -static const char *zconf_tokenname(int token) +static bool zconf_endtoken(const char *tokenname, + const char *expected_tokenname) { - switch (token) { - case T_MENU: return "menu"; - case T_ENDMENU: return "endmenu"; - case T_CHOICE: return "choice"; - case T_ENDCHOICE: return "endchoice"; - case T_IF: return "if"; - case T_ENDIF: return "endif"; - case T_DEPENDS: return "depends"; - case T_VISIBLE: return "visible"; - } - return ""; -} - -static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken) -{ - if (id->token != endtoken) { + if (strcmp(tokenname, expected_tokenname)) { zconf_error("unexpected '%s' within %s block", - id->name, zconf_tokenname(starttoken)); + tokenname, expected_tokenname); yynerrs++; return false; } if (current_menu->file != current_file) { zconf_error("'%s' in different file than '%s'", - id->name, zconf_tokenname(starttoken)); + tokenname, expected_tokenname); fprintf(stderr, "%s:%d: location of the '%s'\n", current_menu->file->name, current_menu->lineno, - zconf_tokenname(starttoken)); + expected_tokenname); yynerrs++; return false; } From b3d1d9d3c36214a50c18ba377b47152c021768df Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:07 +0900 Subject: [PATCH 30/39] kconfig: stop associating kconf_id with yylval The lexer has conventionally associated kconf_id data with yylval to carry additional information to the parser. No token is relying on this any more. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 2 -- scripts/kconfig/zconf.y | 41 ++++++++++++++++++++--------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 90d2f37159dc..ed0d0a3b0d62 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -104,7 +104,6 @@ n [A-Za-z0-9_-] current_pos.lineno = yylineno; if (id && id->flags & TF_COMMAND) { BEGIN(PARAM); - yylval.id = id; return id->token; } alloc_string(yytext, yyleng); @@ -163,7 +162,6 @@ n [A-Za-z0-9_-] {n}+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); if (id && id->flags & TF_PARAM) { - yylval.id = id; return id->token; } alloc_string(yytext, yyleng); diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 71c2fe737e37..3a3ada6f0729 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -40,50 +40,49 @@ static struct menu *current_menu, *current_entry; struct symbol *symbol; struct expr *expr; struct menu *menu; - const struct kconf_id *id; enum symbol_type type; enum variable_flavor flavor; } -%token T_MAINMENU -%token T_MENU -%token T_ENDMENU -%token T_SOURCE -%token T_CHOICE -%token T_ENDCHOICE -%token T_COMMENT -%token T_CONFIG -%token T_MENUCONFIG -%token T_HELP %token T_HELPTEXT -%token T_IF -%token T_ENDIF -%token T_DEPENDS -%token T_OPTIONAL -%token T_PROMPT -%token T_SELECT -%token T_IMPLY -%token T_RANGE -%token T_VISIBLE -%token T_ON %token T_WORD %token T_WORD_QUOTE %token T_ALLNOCONFIG_Y %token T_BOOL +%token T_CHOICE %token T_CLOSE_PAREN %token T_COLON_EQUAL +%token T_COMMENT +%token T_CONFIG %token T_DEFAULT %token T_DEFCONFIG_LIST %token T_DEF_BOOL %token T_DEF_TRISTATE +%token T_DEPENDS +%token T_ENDCHOICE +%token T_ENDIF +%token T_ENDMENU +%token T_HELP %token T_HEX +%token T_IF +%token T_IMPLY %token T_INT +%token T_MAINMENU +%token T_MENU +%token T_MENUCONFIG %token T_MODULES +%token T_ON %token T_OPEN_PAREN %token T_OPTION +%token T_OPTIONAL %token T_PLUS_EQUAL +%token T_PROMPT +%token T_RANGE +%token T_SELECT +%token T_SOURCE %token T_STRING %token T_TRISTATE +%token T_VISIBLE %token T_EOL %token T_ASSIGN_VAL From 824fa3b3b5e3647de0530328e8734c24418eec49 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:08 +0900 Subject: [PATCH 31/39] kconfig: switch to ASSIGN_VAL state in the second lexer To simplify the generated lexer, switch to the ASSIGN_VAL state in the hand-made lexer. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index ed0d0a3b0d62..05e2d95e3b22 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -25,6 +25,7 @@ static struct { int lineno; } current_pos; +static int prev_prev_token = T_EOL; static int prev_token = T_EOL; static char *text; static int text_size, text_asize; @@ -117,9 +118,9 @@ n [A-Za-z0-9_-] return T_WORD; free(yylval.string); } - "=" { BEGIN(ASSIGN_VAL); return T_EQUAL; } - ":=" { BEGIN(ASSIGN_VAL); return T_COLON_EQUAL; } - "+=" { BEGIN(ASSIGN_VAL); return T_PLUS_EQUAL; } + "=" return T_EQUAL; + ":=" return T_COLON_EQUAL; + "+=" return T_PLUS_EQUAL; [[:blank:]]+ . warn_ignored_character(*yytext); \n { @@ -288,6 +289,11 @@ repeat: if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL) goto repeat; + if (prev_prev_token == T_EOL && prev_token == T_WORD && + (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL)) + BEGIN(ASSIGN_VAL); + + prev_prev_token = prev_token; prev_token = token; return token; From 4b31a32caf0a28e4726f1bf267ff8a804ed864e2 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:09 +0900 Subject: [PATCH 32/39] kconfig: update current_pos in the second lexer To simplify the generated lexer, let the hand-made lexer update the file name and line number for the parser. I tested this with DEBUG_PARSE, and confirmed the same file names and line numbers were dumped. Signed-off-by: Masahiro Yamada --- scripts/kconfig/zconf.l | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 05e2d95e3b22..9b083a176fb4 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -101,8 +101,6 @@ n [A-Za-z0-9_-] { {n}+ { const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - current_pos.file = current_file; - current_pos.lineno = yylineno; if (id && id->flags & TF_COMMAND) { BEGIN(PARAM); return id->token; @@ -285,9 +283,21 @@ int yylex(void) repeat: token = yylex1(); - /* Do not pass unneeded T_EOL to the parser. */ - if ((prev_token == T_EOL || prev_token == T_HELPTEXT) && token == T_EOL) - goto repeat; + if (prev_token == T_EOL || prev_token == T_HELPTEXT) { + if (token == T_EOL) { + /* Do not pass unneeded T_EOL to the parser. */ + goto repeat; + } else { + /* + * For the parser, update file/lineno at the first token + * of each statement. Generally, \n is a statement + * terminator in Kconfig, but it is not always true + * because \n could be escaped by a backslash. + */ + current_pos.file = current_file; + current_pos.lineno = yylineno; + } + } if (prev_prev_token == T_EOL && prev_token == T_WORD && (token == T_EQUAL || token == T_COLON_EQUAL || token == T_PLUS_EQUAL)) From 979f2b2f7936f4b71a3100baf2d16c8057f027eb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 11 Dec 2018 20:01:10 +0900 Subject: [PATCH 33/39] kconfig: remove keyword lookup table entirely Commit 7a88488bbc23 ("[PATCH] kconfig: use gperf for kconfig keywords") introduced gperf for the keyword lookup. Then, commit bb3290d91695 ("Remove gperf usage from toolchain") killed the gperf use. As a result, the linear keyword search was left behind. If we do not use gperf, there is no reason to have the separate table of the keywords. Move all keywords back to the lexer. I also refactored the lexer to remove the COMMAND and PARAM states. Signed-off-by: Masahiro Yamada --- scripts/kconfig/kconf_id.c | 49 ------------ scripts/kconfig/lkc.h | 9 --- scripts/kconfig/zconf.l | 153 +++++++++++++++++-------------------- scripts/kconfig/zconf.y | 5 -- 4 files changed, 69 insertions(+), 147 deletions(-) delete mode 100644 scripts/kconfig/kconf_id.c diff --git a/scripts/kconfig/kconf_id.c b/scripts/kconfig/kconf_id.c deleted file mode 100644 index f8b222cc8b87..000000000000 --- a/scripts/kconfig/kconf_id.c +++ /dev/null @@ -1,49 +0,0 @@ - -static struct kconf_id kconf_id_array[] = { - { "mainmenu", T_MAINMENU, TF_COMMAND }, - { "menu", T_MENU, TF_COMMAND }, - { "endmenu", T_ENDMENU, TF_COMMAND }, - { "source", T_SOURCE, TF_COMMAND }, - { "choice", T_CHOICE, TF_COMMAND }, - { "endchoice", T_ENDCHOICE, TF_COMMAND }, - { "comment", T_COMMENT, TF_COMMAND }, - { "config", T_CONFIG, TF_COMMAND }, - { "menuconfig", T_MENUCONFIG, TF_COMMAND }, - { "help", T_HELP, TF_COMMAND }, - { "---help---", T_HELP, TF_COMMAND }, - { "if", T_IF, TF_COMMAND|TF_PARAM }, - { "endif", T_ENDIF, TF_COMMAND }, - { "depends", T_DEPENDS, TF_COMMAND }, - { "optional", T_OPTIONAL, TF_COMMAND }, - { "default", T_DEFAULT, TF_COMMAND }, - { "def_bool", T_DEF_BOOL, TF_COMMAND }, - { "def_tristate", T_DEF_TRISTATE, TF_COMMAND }, - { "prompt", T_PROMPT, TF_COMMAND }, - { "bool", T_BOOL, TF_COMMAND }, - { "tristate", T_TRISTATE, TF_COMMAND }, - { "int", T_INT, TF_COMMAND }, - { "hex", T_HEX, TF_COMMAND }, - { "string", T_STRING, TF_COMMAND }, - { "select", T_SELECT, TF_COMMAND }, - { "imply", T_IMPLY, TF_COMMAND }, - { "range", T_RANGE, TF_COMMAND }, - { "visible", T_VISIBLE, TF_COMMAND }, - { "option", T_OPTION, TF_COMMAND }, - { "on", T_ON, TF_PARAM }, -}; - -#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id)) - -static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len) -{ - int i; - - for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) { - struct kconf_id *id = kconf_id_array+i; - int l = strlen(id->name); - - if (len == l && !memcmp(str, id->name, len)) - return id; - } - return NULL; -} diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 5f4880a12246..ff6b3e414788 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -30,9 +30,6 @@ static inline const char *CONFIG_prefix(void) #undef CONFIG_ #define CONFIG_ CONFIG_prefix() -#define TF_COMMAND 0x0001 -#define TF_PARAM 0x0002 - enum conf_def_mode { def_default, def_yes, @@ -41,12 +38,6 @@ enum conf_def_mode { def_random }; -struct kconf_id { - const char *name; - int token; - unsigned int flags; -}; - extern int yylineno; void zconfdump(FILE *out); void zconf_starthelp(void); diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 9b083a176fb4..d78efad64f51 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -1,6 +1,6 @@ %option nostdinit noyywrap never-interactive full ecs %option 8bit nodefault yylineno -%x COMMAND HELP STRING PARAM ASSIGN_VAL +%x ASSIGN_VAL HELP STRING %{ /* * Copyright (C) 2002 Roman Zippel @@ -87,45 +87,73 @@ n [A-Za-z0-9_-] int str = 0; int ts, i; -[ \t]*#.*\n | -[ \t]*\n { - return T_EOL; -} -[ \t]*#.* -. { - unput(yytext[0]); - BEGIN(COMMAND); -} - - -{ - {n}+ { - const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - if (id && id->flags & TF_COMMAND) { - BEGIN(PARAM); - return id->token; - } - alloc_string(yytext, yyleng); - yylval.string = text; - return T_WORD; - } - ({n}|$)+ { - /* this token includes at least one '$' */ - yylval.string = expand_token(yytext, yyleng); - if (strlen(yylval.string)) - return T_WORD; - free(yylval.string); - } - "=" return T_EQUAL; - ":=" return T_COLON_EQUAL; - "+=" return T_PLUS_EQUAL; - [[:blank:]]+ - . warn_ignored_character(*yytext); - \n { - BEGIN(INITIAL); - return T_EOL; - } -} +#.* /* ignore comment */ +[ \t]* /* whitespaces */ +\\\n /* escaped new line */ +\n return T_EOL; +"allnoconfig_y" return T_ALLNOCONFIG_Y; +"bool" return T_BOOL; +"choice" return T_CHOICE; +"comment" return T_COMMENT; +"config" return T_CONFIG; +"def_bool" return T_DEF_BOOL; +"def_tristate" return T_DEF_TRISTATE; +"default" return T_DEFAULT; +"defconfig_list" return T_DEFCONFIG_LIST; +"depends" return T_DEPENDS; +"endchoice" return T_ENDCHOICE; +"endif" return T_ENDIF; +"endmenu" return T_ENDMENU; +"help"|"---help---" return T_HELP; +"hex" return T_HEX; +"if" return T_IF; +"imply" return T_IMPLY; +"int" return T_INT; +"mainmenu" return T_MAINMENU; +"menu" return T_MENU; +"menuconfig" return T_MENUCONFIG; +"modules" return T_MODULES; +"on" return T_ON; +"option" return T_OPTION; +"optional" return T_OPTIONAL; +"prompt" return T_PROMPT; +"range" return T_RANGE; +"select" return T_SELECT; +"source" return T_SOURCE; +"string" return T_STRING; +"tristate" return T_TRISTATE; +"visible" return T_VISIBLE; +"||" return T_OR; +"&&" return T_AND; +"=" return T_EQUAL; +"!=" return T_UNEQUAL; +"<" return T_LESS; +"<=" return T_LESS_EQUAL; +">" return T_GREATER; +">=" return T_GREATER_EQUAL; +"!" return T_NOT; +"(" return T_OPEN_PAREN; +")" return T_CLOSE_PAREN; +":=" return T_COLON_EQUAL; +"+=" return T_PLUS_EQUAL; +\"|\' { + str = yytext[0]; + new_string(); + BEGIN(STRING); + } +{n}+ { + alloc_string(yytext, yyleng); + yylval.string = text; + return T_WORD; + } +({n}|$)+ { + /* this token includes at least one '$' */ + yylval.string = expand_token(yytext, yyleng); + if (strlen(yylval.string)) + return T_WORD; + free(yylval.string); + } +. warn_ignored_character(*yytext); { [^[:blank:]\n]+.* { @@ -137,49 +165,6 @@ n [A-Za-z0-9_-] . } -{ - "modules" return T_MODULES; - "defconfig_list" return T_DEFCONFIG_LIST; - "allnoconfig_y" return T_ALLNOCONFIG_Y; - "&&" return T_AND; - "||" return T_OR; - "(" return T_OPEN_PAREN; - ")" return T_CLOSE_PAREN; - "!" return T_NOT; - "=" return T_EQUAL; - "!=" return T_UNEQUAL; - "<=" return T_LESS_EQUAL; - ">=" return T_GREATER_EQUAL; - "<" return T_LESS; - ">" return T_GREATER; - \"|\' { - str = yytext[0]; - new_string(); - BEGIN(STRING); - } - \n BEGIN(INITIAL); return T_EOL; - {n}+ { - const struct kconf_id *id = kconf_id_lookup(yytext, yyleng); - if (id && id->flags & TF_PARAM) { - return id->token; - } - alloc_string(yytext, yyleng); - yylval.string = text; - return T_WORD; - } - ({n}|$)+ { - /* this token includes at least one '$' */ - yylval.string = expand_token(yytext, yyleng); - if (strlen(yylval.string)) - return T_WORD; - free(yylval.string); - } - #.* /* comment */ - \\\n ; - [[:blank:]]+ - . warn_ignored_character(*yytext); -} - { "$".* append_expanded_string(yytext); [^$'"\\\n]+ { @@ -190,7 +175,7 @@ n [A-Za-z0-9_-] } \'|\" { if (str == yytext[0]) { - BEGIN(PARAM); + BEGIN(INITIAL); yylval.string = text; return T_WORD_QUOTE; } else diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 3a3ada6f0729..6fb80f210dfb 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -110,11 +110,6 @@ static struct menu *current_menu, *current_entry; menu_end_menu(); } if_entry menu_entry choice_entry -%{ -/* Include kconf_id.c here so it can see the token constants. */ -#include "kconf_id.c" -%} - %% input: mainmenu_stmt stmt_list | stmt_list; From 0c874100108f03401cb3154801d2671bbad40ad4 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 18 Dec 2018 21:13:35 +0900 Subject: [PATCH 34/39] 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 --- scripts/kconfig/conf.c | 2 +- scripts/kconfig/confdata.c | 2 +- scripts/kconfig/expr.c | 2 +- scripts/kconfig/expr.h | 2 +- scripts/kconfig/gconf.c | 5 +---- scripts/kconfig/images.c | 2 +- scripts/kconfig/lkc.h | 2 +- scripts/kconfig/lxdialog/checklist.c | 15 +-------------- scripts/kconfig/lxdialog/dialog.h | 15 +-------------- scripts/kconfig/lxdialog/inputbox.c | 15 +-------------- scripts/kconfig/lxdialog/menubox.c | 15 +-------------- scripts/kconfig/lxdialog/textbox.c | 15 +-------------- scripts/kconfig/lxdialog/util.c | 15 +-------------- scripts/kconfig/lxdialog/yesno.c | 15 +-------------- scripts/kconfig/mconf.c | 2 +- scripts/kconfig/menu.c | 2 +- scripts/kconfig/merge_config.sh | 11 ++--------- scripts/kconfig/nconf.c | 5 ++--- scripts/kconfig/nconf.gui.c | 5 ++--- scripts/kconfig/nconf.h | 5 ++--- scripts/kconfig/qconf.cc | 2 +- scripts/kconfig/qconf.h | 2 +- scripts/kconfig/streamline_config.pl | 2 +- scripts/kconfig/symbol.c | 2 +- scripts/kconfig/tests/auto_submenu/Kconfig | 2 ++ scripts/kconfig/tests/auto_submenu/__init__.py | 1 + scripts/kconfig/tests/choice/Kconfig | 2 ++ scripts/kconfig/tests/choice/__init__.py | 1 + .../kconfig/tests/choice_value_with_m_dep/Kconfig | 2 ++ .../tests/choice_value_with_m_dep/__init__.py | 1 + .../kconfig/tests/err_recursive_inc/__init__.py | 1 + scripts/kconfig/tests/inter_choice/Kconfig | 2 ++ scripts/kconfig/tests/inter_choice/__init__.py | 1 + scripts/kconfig/tests/new_choice_with_dep/Kconfig | 2 ++ .../kconfig/tests/new_choice_with_dep/__init__.py | 1 + .../kconfig/tests/no_write_if_dep_unmet/Kconfig | 2 ++ .../tests/no_write_if_dep_unmet/__init__.py | 1 + scripts/kconfig/tests/rand_nested_choice/Kconfig | 2 ++ .../kconfig/tests/rand_nested_choice/__init__.py | 1 + scripts/kconfig/util.c | 3 +-- scripts/kconfig/zconf.l | 8 ++++---- scripts/kconfig/zconf.y | 4 ++-- 42 files changed, 57 insertions(+), 140 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 98e0c7a34699..da89ef788a8d 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 9ef135735cfa..83f78e5c137e 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 57ebf71291a7..3ff8c92c86ba 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 2b7e222b0784..999edb60cd53 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -1,6 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #ifndef EXPR_H diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 36f578415c4a..14fc0fa5e68c 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1,9 +1,6 @@ -/* Hey EMACS -*- linux-c -*- */ +// SPDX-License-Identifier: GPL-2.0 /* - * * Copyright (C) 2002-2003 Romain Lievin - * Released under the terms of the GNU GPL v2.0. - * */ #ifdef HAVE_CONFIG_H diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c index d4f84bd4a96b..ef43b81c516c 100644 --- a/scripts/kconfig/images.c +++ b/scripts/kconfig/images.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ static const char *xpm_load[] = { diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index ff6b3e414788..4ff33cd099cd 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -1,6 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #ifndef LKC_H diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index 2e96323ad11b..fd161cfff121 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * checklist.c -- implements the checklist box * @@ -5,20 +6,6 @@ * Stuart Herbert - S.Herbert@sheffield.ac.uk: radiolist extension * Alessandro Rubini - rubini@ipvvis.unipv.it: merged the two * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 0b00be5abaa6..68b565e3c495 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -1,21 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * dialog.h -- common declarations for all dialog modules * * AUTHOR: Savio Lam (lam836@cs.cuhk.hk) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index fe82ff6d744e..611945611bf8 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * inputbox.c -- implements the input box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index d70cab36137e..58c2f8afe59b 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * menubox.c -- implements the menu box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcapw@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index 88d2818ed956..4e339b12664e 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * textbox.c -- implements the text box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index f7abdeb92af0..1b490d4af0d3 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * util.c * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c index cd1223c903d1..bcaac9b7bab2 100644 --- a/scripts/kconfig/lxdialog/yesno.c +++ b/scripts/kconfig/lxdialog/yesno.c @@ -1,22 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * yesno.c -- implements the yes/no box * * ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk) * MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "dialog.h" diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 143c05fec161..5f8c82a4cb08 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. * * Introduced single menu mode (show all sub-menus in one large tree). * 2002-11-06 Petr Baudis diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 7e2b2c938d7b..d9d16469859a 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/merge_config.sh b/scripts/kconfig/merge_config.sh index 9b89791b202c..d924c51d28b7 100755 --- a/scripts/kconfig/merge_config.sh +++ b/scripts/kconfig/merge_config.sh @@ -1,4 +1,6 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# # merge_config.sh - Takes a list of config fragment values, and merges # them one by one. Provides warnings on overridden values, and specified # values that did not make it to the resulting .config file (due to missed @@ -10,15 +12,6 @@ # # Copyright (c) 2009-2010 Wind River Systems, Inc. # Copyright 2011 Linaro -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the GNU General Public License for more details. clean_up() { rm -f $TMP_FILE diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 1ef232ae5ab9..a4670f4e825a 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2008 Nir Tzachar * * Derived from menuconfig. - * */ #ifndef _GNU_SOURCE #define _GNU_SOURCE diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 88874acfda36..7be620a1fcdb 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* - * Copyright (C) 2008 Nir Tzachar * * Derived from menuconfig. - * */ #include "nconf.h" #include "lkc.h" diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h index 2b9e19f603c4..fa5245eb93a7 100644 --- a/scripts/kconfig/nconf.h +++ b/scripts/kconfig/nconf.h @@ -1,9 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (C) 2008 Nir Tzachar * * Derived from menuconfig. - * */ #include diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index ef4310f2558b..c897998f9652 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1,7 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel * Copyright (C) 2015 Boris Barbulovski - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index a40036d1b059..41df466e67d9 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -1,6 +1,6 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index 4686531e2f8c..08d76d7b3b81 100755 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -1,7 +1,7 @@ #!/usr/bin/env perl +# SPDX-License-Identifier: GPL-2.0 # # Copyright 2005-2009 - Steven Rostedt -# Licensed under the terms of the GNU GPL License version 2 # # It's simple enough to figure out how this works. # If not, then you can ask me at stripconfig@goodmis.org diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 2e6bf362d164..d1457836e92a 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -1,6 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/tests/auto_submenu/Kconfig b/scripts/kconfig/tests/auto_submenu/Kconfig index c17bf2caa7e6..b20761edc2f4 100644 --- a/scripts/kconfig/tests/auto_submenu/Kconfig +++ b/scripts/kconfig/tests/auto_submenu/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + config A bool "A" default y diff --git a/scripts/kconfig/tests/auto_submenu/__init__.py b/scripts/kconfig/tests/auto_submenu/__init__.py index 32e79b85faeb..25abd927fd0a 100644 --- a/scripts/kconfig/tests/auto_submenu/__init__.py +++ b/scripts/kconfig/tests/auto_submenu/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Create submenu for symbols that depend on the preceding one. diff --git a/scripts/kconfig/tests/choice/Kconfig b/scripts/kconfig/tests/choice/Kconfig index cc60e9ce2c03..a412205b1b0c 100644 --- a/scripts/kconfig/tests/choice/Kconfig +++ b/scripts/kconfig/tests/choice/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + config MODULES bool "Enable loadable module support" option modules diff --git a/scripts/kconfig/tests/choice/__init__.py b/scripts/kconfig/tests/choice/__init__.py index 9edcc5262134..4318fce05912 100644 --- a/scripts/kconfig/tests/choice/__init__.py +++ b/scripts/kconfig/tests/choice/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Basic choice tests. diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig b/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig index 11ac25c26040..7106c26bb3a8 100644 --- a/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig +++ b/scripts/kconfig/tests/choice_value_with_m_dep/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + config MODULES def_bool y option modules diff --git a/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py b/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py index f8d728c7b101..075b4e08696e 100644 --- a/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py +++ b/scripts/kconfig/tests/choice_value_with_m_dep/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Hide tristate choice values with mod dependency in y choice. diff --git a/scripts/kconfig/tests/err_recursive_inc/__init__.py b/scripts/kconfig/tests/err_recursive_inc/__init__.py index 0e4c839c54aa..27aa1895a0b2 100644 --- a/scripts/kconfig/tests/err_recursive_inc/__init__.py +++ b/scripts/kconfig/tests/err_recursive_inc/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Detect recursive inclusion error. diff --git a/scripts/kconfig/tests/inter_choice/Kconfig b/scripts/kconfig/tests/inter_choice/Kconfig index e44449f075df..5698a4018dd0 100644 --- a/scripts/kconfig/tests/inter_choice/Kconfig +++ b/scripts/kconfig/tests/inter_choice/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + config MODULES def_bool y option modules diff --git a/scripts/kconfig/tests/inter_choice/__init__.py b/scripts/kconfig/tests/inter_choice/__init__.py index 5c7fc365ed40..ffea6b1148a6 100644 --- a/scripts/kconfig/tests/inter_choice/__init__.py +++ b/scripts/kconfig/tests/inter_choice/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Do not affect user-assigned choice value by another choice. diff --git a/scripts/kconfig/tests/new_choice_with_dep/Kconfig b/scripts/kconfig/tests/new_choice_with_dep/Kconfig index 53ef1b86e7bf..127731c046b5 100644 --- a/scripts/kconfig/tests/new_choice_with_dep/Kconfig +++ b/scripts/kconfig/tests/new_choice_with_dep/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + config A bool "A" help diff --git a/scripts/kconfig/tests/new_choice_with_dep/__init__.py b/scripts/kconfig/tests/new_choice_with_dep/__init__.py index f0e0ead0f32f..fe9d322539c9 100644 --- a/scripts/kconfig/tests/new_choice_with_dep/__init__.py +++ b/scripts/kconfig/tests/new_choice_with_dep/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Ask new choice values when they become visible. diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig b/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig index c00b8fe54f45..4767aab6d8e3 100644 --- a/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + config A bool "A" diff --git a/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py index 207261b0fe00..ffd469d1f226 100644 --- a/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py +++ b/scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Do not write choice values to .config if the dependency is unmet. diff --git a/scripts/kconfig/tests/rand_nested_choice/Kconfig b/scripts/kconfig/tests/rand_nested_choice/Kconfig index c591d512929f..8350de7f732b 100644 --- a/scripts/kconfig/tests/rand_nested_choice/Kconfig +++ b/scripts/kconfig/tests/rand_nested_choice/Kconfig @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + choice prompt "choice" diff --git a/scripts/kconfig/tests/rand_nested_choice/__init__.py b/scripts/kconfig/tests/rand_nested_choice/__init__.py index e729a4e85218..9e4b2db53581 100644 --- a/scripts/kconfig/tests/rand_nested_choice/__init__.py +++ b/scripts/kconfig/tests/rand_nested_choice/__init__.py @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 """ Set random values recursively in nested choices. diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index d999683bb2a7..29585394df71 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -1,8 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2002-2005 Roman Zippel * Copyright (C) 2002-2005 Sam Ravnborg - * - * Released under the terms of the GNU GPL v2.0. */ #include diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index d78efad64f51..96f8b1dcf470 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -1,11 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2002 Roman Zippel + */ %option nostdinit noyywrap never-interactive full ecs %option 8bit nodefault yylineno %x ASSIGN_VAL HELP STRING %{ -/* - * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. - */ #include #include diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 6fb80f210dfb..0d590cb07b71 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -1,8 +1,8 @@ -%{ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2002 Roman Zippel - * Released under the terms of the GNU GPL v2.0. */ +%{ #include #include From 558e78e3ce844c61ceffe32775dbefacf167b023 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 21 Dec 2018 17:33:04 +0900 Subject: [PATCH 35/39] 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 --- scripts/kconfig/Makefile | 19 +++++++++---------- scripts/kconfig/confdata.c | 1 + scripts/kconfig/expr.c | 2 ++ scripts/kconfig/lkc.h | 1 + scripts/kconfig/preprocess.c | 2 ++ scripts/kconfig/symbol.c | 2 +- scripts/kconfig/zconf.y | 4 ---- 7 files changed, 16 insertions(+), 15 deletions(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 63b609243d03..d3bd68754750 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -142,13 +142,8 @@ help: @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' # =========================================================================== -# Shared Makefile for the various kconfig executables: -# conf: Used for defconfig, oldconfig and related targets # object files used by all kconfig flavours - -conf-objs := conf.o zconf.tab.o - -hostprogs-y := conf +common-objs := confdata.o expr.o symbol.o preprocess.o zconf.tab.o targets += zconf.lex.c @@ -156,9 +151,13 @@ targets += zconf.lex.c HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) +# conf: Used for defconfig, oldconfig and related targets +hostprogs-y += conf +conf-objs := conf.o $(common-objs) + # nconf: Used for the nconfig target based on ncurses hostprogs-y += nconf -nconf-objs := nconf.o zconf.tab.o nconf.gui.o +nconf-objs := nconf.o nconf.gui.o $(common-objs) HOSTLDLIBS_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs) HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags) @@ -169,7 +168,7 @@ $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg # mconf: Used for the menuconfig target based on lxdialog hostprogs-y += mconf lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o -mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog)) +mconf-objs := mconf.o $(addprefix lxdialog/, $(lxdialog)) $(common-objs) HOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs) $(foreach f, mconf.o $(lxdialog), \ @@ -181,7 +180,7 @@ $(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg # qconf: Used for the xconfig target based on Qt hostprogs-y += qconf qconf-cxxobjs := qconf.o -qconf-objs := zconf.tab.o +qconf-objs := $(common-objs) HOSTLDLIBS_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs) HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags) @@ -196,7 +195,7 @@ $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg # gconf: Used for the gconfig target based on GTK+ hostprogs-y += gconf -gconf-objs := gconf.o zconf.tab.o +gconf-objs := gconf.o $(common-objs) HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs) HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 83f78e5c137e..08ba146a83c5 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 3ff8c92c86ba..77ffff3a053c 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -3,6 +3,8 @@ * Copyright (C) 2002 Roman Zippel */ +#include +#include #include #include #include diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 4ff33cd099cd..160a9312e11a 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -108,6 +108,7 @@ const char *str_get(struct gstr *gs); /* symbol.c */ void sym_clear_all_valid(void); struct symbol *sym_choice_default(struct symbol *sym); +struct property *sym_get_range_prop(struct symbol *sym); const char *sym_get_string_default(struct symbol *sym); struct symbol *sym_check_deps(struct symbol *sym); struct property *prop_alloc(enum prop_type type, struct symbol *sym); diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c index b028a48b0e76..592dfbfa9fb3 100644 --- a/scripts/kconfig/preprocess.c +++ b/scripts/kconfig/preprocess.c @@ -2,6 +2,7 @@ // // Copyright (C) 2018 Masahiro Yamada +#include #include #include #include @@ -9,6 +10,7 @@ #include #include "list.h" +#include "lkc.h" #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index d1457836e92a..1f9266dadedf 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -86,7 +86,7 @@ static struct property *sym_get_default_prop(struct symbol *sym) return NULL; } -static struct property *sym_get_range_prop(struct symbol *sym) +struct property *sym_get_range_prop(struct symbol *sym) { struct property *prop; diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 0d590cb07b71..a990f46f3825 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -731,8 +731,4 @@ void zconfdump(FILE *out) #include "zconf.lex.c" #include "util.c" -#include "confdata.c" -#include "expr.c" -#include "symbol.c" #include "menu.c" -#include "preprocess.c" From cbafbf7f551c3a03fb9440932f1ca13056ca40a6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 21 Dec 2018 17:33:05 +0900 Subject: [PATCH 36/39] kconfig: split the lexer out of zconf.y Compile zconf.lex.c independently of the other files. Signed-off-by: Masahiro Yamada --- scripts/kconfig/Makefile | 8 ++------ scripts/kconfig/lkc.h | 3 +++ scripts/kconfig/zconf.l | 1 + scripts/kconfig/zconf.y | 2 -- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index d3bd68754750..65cdf8c36cb4 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -143,11 +143,9 @@ help: # =========================================================================== # object files used by all kconfig flavours -common-objs := confdata.o expr.o symbol.o preprocess.o zconf.tab.o +common-objs := confdata.o expr.o symbol.o preprocess.o zconf.lex.o zconf.tab.o -targets += zconf.lex.c - -# generated files seem to need this to find local include files +$(obj)/zconf.lex.o: $(obj)/zconf.tab.h HOSTCFLAGS_zconf.lex.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) @@ -202,8 +200,6 @@ HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags) $(obj)/gconf.o: $(obj)/.gconf-cfg -$(obj)/zconf.tab.o: $(obj)/zconf.lex.c - # check if necessary packages are available, and configure build flags define filechk_conf_cfg $(CONFIG_SHELL) $< diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 160a9312e11a..531ff7c57d92 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -90,6 +90,9 @@ void *xrealloc(void *p, size_t size); char *xstrdup(const char *s); char *xstrndup(const char *s, size_t n); +/* zconf.l */ +int yylex(void); + struct gstr { size_t len; char *s; diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 96f8b1dcf470..b2d0a3b0bce9 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -15,6 +15,7 @@ #include #include "lkc.h" +#include "zconf.tab.h" #define YY_DECL static int yylex1(void) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index a990f46f3825..69409abc7dc2 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -20,7 +20,6 @@ int cdebug = PRINTD; -int yylex(void); static void yyerror(const char *err); static void zconfprint(const char *err, ...); static void zconf_error(const char *err, ...); @@ -729,6 +728,5 @@ void zconfdump(FILE *out) } } -#include "zconf.lex.c" #include "util.c" #include "menu.c" From 9abe42371b44ef3e10e068d3e461c3a97192fb46 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 21 Dec 2018 17:33:06 +0900 Subject: [PATCH 37/39] kconfig: add static qualifiers to fix gconf warnings Add "static" to functions that are locally used in gconf.c This fixes some "no previous prototype for ..." warnings. Signed-off-by: Masahiro Yamada --- scripts/kconfig/gconf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 14fc0fa5e68c..2d4e5a1e3a30 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -76,7 +76,7 @@ static void conf_changed(void); /* Helping/Debugging Functions */ -const char *dbg_sym_flags(int val) +static const char *dbg_sym_flags(int val) { static char buf[256]; @@ -106,8 +106,8 @@ const char *dbg_sym_flags(int val) return buf; } -void replace_button_icon(GladeXML * xml, GdkDrawable * window, - GtkStyle * style, gchar * btn_name, gchar ** xpm) +static void replace_button_icon(GladeXML *xml, GdkDrawable *window, + GtkStyle *style, gchar *btn_name, gchar **xpm) { GdkPixmap *pixmap; GdkBitmap *mask; @@ -125,7 +125,7 @@ void replace_button_icon(GladeXML * xml, GdkDrawable * window, } /* Main Window Initialization */ -void init_main_window(const gchar * glade_file) +static void init_main_window(const gchar *glade_file) { GladeXML *xml; GtkWidget *widget; @@ -187,7 +187,7 @@ void init_main_window(const gchar * glade_file) gtk_widget_show(main_wnd); } -void init_tree_model(void) +static void init_tree_model(void) { gint i; @@ -217,7 +217,7 @@ void init_tree_model(void) model1 = GTK_TREE_MODEL(tree1); } -void init_left_tree(void) +static void init_left_tree(void) { GtkTreeView *view = GTK_TREE_VIEW(tree1_w); GtkCellRenderer *renderer; @@ -259,7 +259,7 @@ static void renderer_edited(GtkCellRendererText * cell, const gchar * path_string, const gchar * new_text, gpointer user_data); -void init_right_tree(void) +static void init_right_tree(void) { GtkTreeView *view = GTK_TREE_VIEW(tree2_w); GtkCellRenderer *renderer; @@ -1209,8 +1209,8 @@ static GtkTreeIter found; /* * Find a menu in the GtkTree starting at parent. */ -GtkTreeIter *gtktree_iter_find_node(GtkTreeIter * parent, - struct menu *tofind) +static GtkTreeIter *gtktree_iter_find_node(GtkTreeIter *parent, + struct menu *tofind) { GtkTreeIter iter; GtkTreeIter *child = &iter; @@ -1421,7 +1421,7 @@ static void display_list(void) tree = tree2; } -void fixup_rootmenu(struct menu *menu) +static void fixup_rootmenu(struct menu *menu) { struct menu *child; static int menu_cnt = 0; From 3b541978562a0f553b0c0253d927d55612dd97b1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 21 Dec 2018 17:33:07 +0900 Subject: [PATCH 38/39] kconfig: split images.c out of qconf.cc/gconf.c to fix gconf warnings Currently, images.c is included by qconf.cc and gconf.c. qconf.cc uses all of xpm_* arrays, but gconf.c only some of them. Hence, lots of "... defined but not used" warnings are displayed while compiling gconf.c Splitting out images.c fixes the warnings. Signed-off-by: Masahiro Yamada --- scripts/kconfig/Makefile | 4 ++-- scripts/kconfig/gconf.c | 2 +- scripts/kconfig/images.c | 32 +++++++++++++++++--------------- scripts/kconfig/images.h | 33 +++++++++++++++++++++++++++++++++ scripts/kconfig/qconf.cc | 2 +- 5 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 scripts/kconfig/images.h diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 65cdf8c36cb4..ec204fa54c9a 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -178,7 +178,7 @@ $(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg # qconf: Used for the xconfig target based on Qt hostprogs-y += qconf qconf-cxxobjs := qconf.o -qconf-objs := $(common-objs) +qconf-objs := images.o $(common-objs) HOSTLDLIBS_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs) HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags) @@ -193,7 +193,7 @@ $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg # gconf: Used for the gconfig target based on GTK+ hostprogs-y += gconf -gconf-objs := gconf.o $(common-objs) +gconf-objs := gconf.o images.o $(common-objs) HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs) HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 2d4e5a1e3a30..b3d438c531fc 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -9,7 +9,7 @@ #include #include "lkc.h" -#include "images.c" +#include "images.h" #include #include diff --git a/scripts/kconfig/images.c b/scripts/kconfig/images.c index ef43b81c516c..b4fa0e4a63a5 100644 --- a/scripts/kconfig/images.c +++ b/scripts/kconfig/images.c @@ -3,7 +3,9 @@ * Copyright (C) 2002 Roman Zippel */ -static const char *xpm_load[] = { +#include "images.h" + +const char *xpm_load[] = { "22 22 5 1", ". c None", "# c #000000", @@ -33,7 +35,7 @@ static const char *xpm_load[] = { "###############.......", "......................"}; -static const char *xpm_save[] = { +const char *xpm_save[] = { "22 22 5 1", ". c None", "# c #000000", @@ -63,7 +65,7 @@ static const char *xpm_save[] = { "..##################..", "......................"}; -static const char *xpm_back[] = { +const char *xpm_back[] = { "22 22 3 1", ". c None", "# c #000083", @@ -91,7 +93,7 @@ static const char *xpm_back[] = { "......................", "......................"}; -static const char *xpm_tree_view[] = { +const char *xpm_tree_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -118,7 +120,7 @@ static const char *xpm_tree_view[] = { "......................", "......................"}; -static const char *xpm_single_view[] = { +const char *xpm_single_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -145,7 +147,7 @@ static const char *xpm_single_view[] = { "......................", "......................"}; -static const char *xpm_split_view[] = { +const char *xpm_split_view[] = { "22 22 2 1", ". c None", "# c #000000", @@ -172,7 +174,7 @@ static const char *xpm_split_view[] = { "......................", "......................"}; -static const char *xpm_symbol_no[] = { +const char *xpm_symbol_no[] = { "12 12 2 1", " c white", ". c black", @@ -189,7 +191,7 @@ static const char *xpm_symbol_no[] = { " .......... ", " "}; -static const char *xpm_symbol_mod[] = { +const char *xpm_symbol_mod[] = { "12 12 2 1", " c white", ". c black", @@ -206,7 +208,7 @@ static const char *xpm_symbol_mod[] = { " .......... ", " "}; -static const char *xpm_symbol_yes[] = { +const char *xpm_symbol_yes[] = { "12 12 2 1", " c white", ". c black", @@ -223,7 +225,7 @@ static const char *xpm_symbol_yes[] = { " .......... ", " "}; -static const char *xpm_choice_no[] = { +const char *xpm_choice_no[] = { "12 12 2 1", " c white", ". c black", @@ -240,7 +242,7 @@ static const char *xpm_choice_no[] = { " .... ", " "}; -static const char *xpm_choice_yes[] = { +const char *xpm_choice_yes[] = { "12 12 2 1", " c white", ". c black", @@ -257,7 +259,7 @@ static const char *xpm_choice_yes[] = { " .... ", " "}; -static const char *xpm_menu[] = { +const char *xpm_menu[] = { "12 12 2 1", " c white", ". c black", @@ -274,7 +276,7 @@ static const char *xpm_menu[] = { " .......... ", " "}; -static const char *xpm_menu_inv[] = { +const char *xpm_menu_inv[] = { "12 12 2 1", " c white", ". c black", @@ -291,7 +293,7 @@ static const char *xpm_menu_inv[] = { " .......... ", " "}; -static const char *xpm_menuback[] = { +const char *xpm_menuback[] = { "12 12 2 1", " c white", ". c black", @@ -308,7 +310,7 @@ static const char *xpm_menuback[] = { " .......... ", " "}; -static const char *xpm_void[] = { +const char *xpm_void[] = { "12 12 2 1", " c white", ". c black", diff --git a/scripts/kconfig/images.h b/scripts/kconfig/images.h new file mode 100644 index 000000000000..d8ff614bd087 --- /dev/null +++ b/scripts/kconfig/images.h @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2002 Roman Zippel + */ + +#ifndef IMAGES_H +#define IMAGES_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern const char *xpm_load[]; +extern const char *xpm_save[]; +extern const char *xpm_back[]; +extern const char *xpm_tree_view[]; +extern const char *xpm_single_view[]; +extern const char *xpm_split_view[]; +extern const char *xpm_symbol_no[]; +extern const char *xpm_symbol_mod[]; +extern const char *xpm_symbol_yes[]; +extern const char *xpm_choice_no[]; +extern const char *xpm_choice_yes[]; +extern const char *xpm_menu[]; +extern const char *xpm_menu_inv[]; +extern const char *xpm_menuback[]; +extern const char *xpm_void[]; + +#ifdef __cplusplus +} +#endif + +#endif /* IMAGES_H */ diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index c897998f9652..8be8a70c5542 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -32,7 +32,7 @@ #include "qconf.h" #include "qconf.moc" -#include "images.c" +#include "images.h" static QApplication *configApp; From f222b7f43661c3dddd44ee493c16e04e8f231542 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 21 Dec 2018 17:33:08 +0900 Subject: [PATCH 39/39] kconfig: surround dbg_sym_flags with #ifdef DEBUG to fix gconf warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following warning: no previous prototype for ‘dbg_sym_flags’ [-Wmissing-prototypes] Signed-off-by: Masahiro Yamada --- scripts/kconfig/gconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index b3d438c531fc..5d4ecf309ee4 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -75,7 +75,7 @@ static gchar **fill_row(struct menu *menu); static void conf_changed(void); /* Helping/Debugging Functions */ - +#ifdef DEBUG static const char *dbg_sym_flags(int val) { static char buf[256]; @@ -105,6 +105,7 @@ static const char *dbg_sym_flags(int val) return buf; } +#endif static void replace_button_icon(GladeXML *xml, GdkDrawable *window, GtkStyle *style, gchar *btn_name, gchar **xpm)