From a44a11e9a049b491445bfbd93969d23c49047714 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Thu, 4 Nov 2010 00:16:08 -0400 Subject: [PATCH 01/13] kconfig: the day kconfig warns about "select"-abuse has come CC: catalin.marinas@arm.com Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- Documentation/kbuild/kconfig-language.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index 2fe93ca7c77c..5b9b1be6fde2 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -112,7 +112,6 @@ applicable everywhere (see syntax). (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over. - kconfig should one day warn about such things. - numerical ranges: "range" ["if" ] This allows to limit the range of possible input values for int From 6e71fabe9e60b1c6db587fbeac349848647920ab Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:31:57 -0500 Subject: [PATCH 02/13] kconfig: do not define AUTOCONF_INCLUDED AUTOCONF_INCLUDED is not checked is not used within the tree and its parent header, `autoconf.h', is safe to be re-included. Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 9df80114b47b..f349bdcffa98 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -833,8 +833,7 @@ int conf_write_autoconf(void) " * Automatically generated C config: don't edit\n" " * %s\n" " * %s" - " */\n" - "#define AUTOCONF_INCLUDED\n", + " */\n", rootmenu.prompt->text, ctime(&now)); for_all_symbols(i, sym) { From 0dce631092f410bb22b21b3d47ef20d69389dfd9 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:33:16 -0500 Subject: [PATCH 03/13] kconfig: nuke second argument of conf_write_symbol() Replacing S_TRISTATE by S_BOOLEAN is a no-op for conf_write_symbol(). Signed-off-by: Arnaud Lacombe [mmarek: Fix unused variable warning in conf_write()] Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index f349bdcffa98..d1bab0f42d10 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -440,12 +440,11 @@ static void conf_write_string(bool headerfile, const char *name, fputs("\"\n", out); } -static void conf_write_symbol(struct symbol *sym, enum symbol_type type, - FILE *out, bool write_no) +static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no) { const char *str; - switch (type) { + switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: switch (sym_get_tristate_value(sym)) { @@ -532,7 +531,7 @@ int conf_write_defconfig(const char *filename) goto next_menu; } } - conf_write_symbol(sym, sym->type, out, true); + conf_write_symbol(sym, out, true); } next_menu: if (menu->list != NULL) { @@ -561,7 +560,6 @@ int conf_write(const char *name) const char *basename; const char *str; char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1]; - enum symbol_type type; time_t now; int use_timestamp = 1; char *env; @@ -633,14 +631,8 @@ int conf_write(const char *name) if (!(sym->flags & SYMBOL_WRITE)) goto next; sym->flags &= ~SYMBOL_WRITE; - type = sym->type; - if (type == S_TRISTATE) { - sym_calc_value(modules_sym); - if (modules_sym->curr.tri == no) - type = S_BOOLEAN; - } /* Write config symbol to file */ - conf_write_symbol(sym, type, out, true); + conf_write_symbol(sym, out, true); } next: @@ -842,7 +834,7 @@ int conf_write_autoconf(void) continue; /* write symbol to config file */ - conf_write_symbol(sym, sym->type, out, false); + conf_write_symbol(sym, out, false); /* update autoconf and tristate files */ switch (sym->type) { From fe04ce0bf955eaf53f7e4cd6bb35976fa94e0925 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:41:14 -0500 Subject: [PATCH 04/13] kbuild/nconf: fix spaces damage Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/nconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 272a987f23e0..eda49ffc1c8c 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -248,7 +248,7 @@ search_help[] = N_( "Only relevant lines are shown.\n" "\n\n" "Search examples:\n" -"Examples: USB = > find all symbols containing USB\n" +"Examples: USB => find all symbols containing USB\n" " ^USB => find all symbols starting with USB\n" " USB$ => find all symbols ending with USB\n" "\n"); From 1ebfa5198ee96f34f2ee4ae95c92318f07341fbd Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:41:15 -0500 Subject: [PATCH 05/13] kbuild/gconf: add dummy inline for bind_textdomain_codeset() This symbols is used by gconf. Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/lkc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 753cdbd7b805..a542c6ba84b3 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -14,6 +14,7 @@ static inline const char *gettext(const char *txt) { return txt; } static inline void textdomain(const char *domainname) {} static inline void bindtextdomain(const char *name, const char *dir) {} +static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; } #endif #ifdef __cplusplus From 579fb8e741fecef7dfd64afcc7b0b0c68ea207cc Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:41:16 -0500 Subject: [PATCH 06/13] kconfig: fix typos Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 6 +++--- scripts/kconfig/symbol.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index d1bab0f42d10..61c35bf2d9cb 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -937,7 +937,7 @@ static void randomize_choice_values(struct symbol *csym) int cnt, def; /* - * If choice is mod then we may have more items slected + * If choice is mod then we may have more items selected * and if no then no-one. * In both cases stop. */ @@ -1033,10 +1033,10 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) /* * We have different type of choice blocks. - * If curr.tri equal to mod then we can select several + * If curr.tri equals to mod then we can select several * choice symbols in one block. * In this case we do nothing. - * If curr.tri equal yes then only one symbol can be + * If curr.tri equals yes then only one symbol can be * selected in a choice block and we set it to yes, * and the rest to no. */ diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index c0efe102d655..60830ce4a0a9 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -686,7 +686,7 @@ const char *sym_get_string_default(struct symbol *sym) switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: - /* The visibility imay limit the value from yes => mod */ + /* The visibility may limit the value from yes => mod */ val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); break; default: From bf128f5265625b8015789ea8f12b3582dc29faa3 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:41:17 -0500 Subject: [PATCH 07/13] kconfig/conf: merge duplicate switch's case Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/conf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 5459a38be866..659326c3e895 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -529,8 +529,6 @@ int main(int ac, char **av) } break; case savedefconfig: - conf_read(NULL); - break; case silentoldconfig: case oldaskconfig: case oldconfig: From 4ce2c1e8e899831dd152bd0d534a60da6fb1582a Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:41:18 -0500 Subject: [PATCH 08/13] kconfig: fix `zconfdebug' extern declaration This symbol is only exist if YYDEBUG is defined. Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/lkc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index a542c6ba84b3..6d38b7c9c824 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -68,10 +68,12 @@ struct kconf_id { enum symbol_type stype; }; +#ifdef YYDEBUG +extern int zconfdebug; +#endif + int zconfparse(void); void zconfdump(FILE *out); - -extern int zconfdebug; void zconf_starthelp(void); FILE *zconf_fopen(const char *name); void zconf_initscan(const char *name); From ab60bd0b92ec57c98df08616b7d0664be5551eae Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Dec 2010 01:29:25 -0500 Subject: [PATCH 09/13] kconfig: add more S_INT and S_HEX consistency checks This patch add more number consistency checkg, trying to catch the following situation: config FOO0 hex default 42 config FOO1 string config BAR0 int default FOO1 config BAR1 hex default FOO1 config FOO2 hex default 42h config FOO3 int default "1bar" Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/menu.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 7e83aef42c6d..8a8bc9be7831 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -183,7 +183,7 @@ void menu_add_option(int token, char *arg) } } -static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2) +static int menu_validate_number(struct symbol *sym, struct symbol *sym2) { return sym2->type == S_INT || sym2->type == S_HEX || (sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name)); @@ -201,6 +201,15 @@ static void sym_check_prop(struct symbol *sym) prop_warn(prop, "default for config symbol '%s'" " must be a single symbol", sym->name); + if (prop->expr->type != E_SYMBOL) + break; + sym2 = prop_get_symbol(prop); + if (sym->type == S_HEX || sym->type == S_INT) { + if (!menu_validate_number(sym, sym2)) + prop_warn(prop, + "'%s': number is invalid", + sym->name); + } break; case P_SELECT: sym2 = prop_get_symbol(prop); @@ -220,8 +229,8 @@ static void sym_check_prop(struct symbol *sym) if (sym->type != S_INT && sym->type != S_HEX) prop_warn(prop, "range is only allowed " "for int or hex symbols"); - if (!menu_range_valid_sym(sym, prop->expr->left.sym) || - !menu_range_valid_sym(sym, prop->expr->right.sym)) + if (!menu_validate_number(sym, prop->expr->left.sym) || + !menu_validate_number(sym, prop->expr->right.sym)) prop_warn(prop, "range is invalid"); break; default: From 1137c56b7420c801147e0863845c03b07554721a Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 26 Sep 2010 16:24:08 -0400 Subject: [PATCH 10/13] kconfig: simplify select-with-unmet-direct-dependency warning This is an attempt to simplify the expressing printed by kconfig when a symbol is selected but still has direct unmet dependency. First, the symbol reverse dependency is split in sub-expression. Then, each sub-expression is checked to ensure that it does not contains the unmet dependency. This removes the false-positive symbols and fixed symbol which already have the correct dependency. Finally, only the symbol responsible of the "select" is printed, instead of its full dependency tree. CC: Catalin Marinas Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/expr.c | 42 ++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/symbol.c | 6 +++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 330e7c0048a8..65531a7f28a8 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1013,6 +1013,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2) #endif } +static inline struct expr * +expr_get_leftmost_symbol(const struct expr *e) +{ + + if (e == NULL) + return NULL; + + while (e->type != E_SYMBOL) + e = e->left.expr; + + return expr_copy(e); +} + +/* + * Given expression `e1' and `e2', returns the leaf of the longest + * sub-expression of `e1' not containing 'e2. + */ +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) +{ + struct expr *ret; + + switch (e1->type) { + case E_OR: + return expr_alloc_and( + expr_simplify_unmet_dep(e1->left.expr, e2), + expr_simplify_unmet_dep(e1->right.expr, e2)); + case E_AND: { + struct expr *e; + e = expr_alloc_and(expr_copy(e1), expr_copy(e2)); + e = expr_eliminate_dups(e); + ret = (!expr_eq(e, e1)) ? e1 : NULL; + expr_free(e); + break; + } + default: + ret = e1; + break; + } + + return expr_get_leftmost_symbol(ret); +} + void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) { if (!e) { diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 60830ce4a0a9..fa52e6f44ac4 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -351,12 +351,16 @@ void sym_calc_value(struct symbol *sym) } calc_newval: if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { + struct expr *e; + e = expr_simplify_unmet_dep(sym->rev_dep.expr, + sym->dir_dep.expr); fprintf(stderr, "warning: ("); - expr_fprint(sym->rev_dep.expr, stderr); + expr_fprint(e, stderr); fprintf(stderr, ") selects %s which has unmet direct dependencies (", sym->name); expr_fprint(sym->dir_dep.expr, stderr); fprintf(stderr, ")\n"); + expr_free(e); } newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); } From 17742dc743716eebbf5892add0e0bf91f541fc39 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Mon, 20 Dec 2010 16:06:44 +0100 Subject: [PATCH 11/13] kconfig: Make expr_copy() take a const argument MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes scripts/kconfig/expr.c: In function ‘expr_get_leftmost_symbol’: scripts/kconfig/expr.c:1026:2: warning: passing argument 1 of ‘expr_copy’ discards qualifiers from pointer target type scripts/kconfig/expr.c:67:14: note: expected ‘struct expr *’ but argument is of type ‘const struct expr *’ Signed-off-by: Michal Marek --- scripts/kconfig/expr.c | 2 +- scripts/kconfig/expr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 65531a7f28a8..001003452f68 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -64,7 +64,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) return e2 ? expr_alloc_two(E_OR, e1, e2) : e1; } -struct expr *expr_copy(struct expr *org) +struct expr *expr_copy(const struct expr *org) { struct expr *e; diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 184eb6a0b505..218991b26d92 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -191,7 +191,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2); struct expr *expr_alloc_and(struct expr *e1, struct expr *e2); struct expr *expr_alloc_or(struct expr *e1, struct expr *e2); -struct expr *expr_copy(struct expr *org); +struct expr *expr_copy(const struct expr *org); void expr_free(struct expr *e); int expr_eq(struct expr *e1, struct expr *e2); void expr_eliminate_eq(struct expr **ep1, struct expr **ep2); From 0597fcd08b858df83b9f20afd6035311d92c48f8 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Thu, 23 Dec 2010 03:25:16 -0500 Subject: [PATCH 12/13] kconfig: fix warning In file included from scripts/kconfig/zconf.tab.c:2502: scripts/kconfig/expr.c:1033: warning: no previous prototype for 'expr_simplify_unmet_dep' Reported-by: Stephen Rothwell Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/expr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 218991b26d92..79ab6e746f53 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -206,6 +206,7 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2); struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2); void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2); struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym); +struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2); void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ From 39177ec36236fb71257e51d0d198437b84170911 Mon Sep 17 00:00:00 2001 From: Peter Korsgaard Date: Thu, 6 Jan 2011 16:42:45 +0100 Subject: [PATCH 13/13] nconf: handle comment entries within choice/endchoice Equivalent to af6c1598 (kconfig: handle comment entries within choice/endchoice), but for nconfig instead. Implement support for comment entries within choice groups. Comment entries are displayed visually distinct from normal configs, and selecting them is a no-op. Signed-off-by: Peter Korsgaard Signed-off-by: Michal Marek --- scripts/kconfig/nconf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index eda49ffc1c8c..db56377393d7 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1266,9 +1266,13 @@ static void conf_choice(struct menu *menu) if (child->sym == sym_get_choice_value(menu->sym)) item_make(child, ':', " %s", _(menu_get_prompt(child))); - else + else if (child->sym) item_make(child, ':', " %s", _(menu_get_prompt(child))); + else + item_make(child, ':', "*** %s ***", + _(menu_get_prompt(child))); + if (child->sym == active){ last_top_row = top_row(curses_menu); selected_index = i; @@ -1334,7 +1338,7 @@ static void conf_choice(struct menu *menu) break; child = item_data(); - if (!child || !menu_is_visible(child)) + if (!child || !menu_is_visible(child) || !child->sym) continue; switch (res) { case ' ':