Skip to content

Commit f28b1c8

Browse files
committed
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: nconf: handle comment entries within choice/endchoice kconfig: fix warning kconfig: Make expr_copy() take a const argument kconfig: simplify select-with-unmet-direct-dependency warning kconfig: add more S_INT and S_HEX consistency checks kconfig: fix `zconfdebug' extern declaration kconfig/conf: merge duplicate switch's case kconfig: fix typos kbuild/gconf: add dummy inline for bind_textdomain_codeset() kbuild/nconf: fix spaces damage kconfig: nuke second argument of conf_write_symbol() kconfig: do not define AUTOCONF_INCLUDED kconfig: the day kconfig warns about "select"-abuse has come
2 parents 0c05384 + 39177ec commit f28b1c8

9 files changed

Lines changed: 84 additions & 33 deletions

File tree

‎Documentation/kbuild/kconfig-language.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ applicable everywhere (see syntax).
112112
(no prompts anywhere) and for symbols with no dependencies.
113113
That will limit the usefulness but on the other hand avoid
114114
the illegal configurations all over.
115-
kconfig should one day warn about such things.
116115

117116
- numerical ranges: "range" <symbol> <symbol> ["if" <expr>]
118117
This allows to limit the range of possible input values for int

‎scripts/kconfig/conf.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,6 @@ int main(int ac, char **av)
529529
}
530530
break;
531531
case savedefconfig:
532-
conf_read(NULL);
533-
break;
534532
case silentoldconfig:
535533
case oldaskconfig:
536534
case oldconfig:

‎scripts/kconfig/confdata.c‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,11 @@ static void conf_write_string(bool headerfile, const char *name,
440440
fputs("\"\n", out);
441441
}
442442

443-
static void conf_write_symbol(struct symbol *sym, enum symbol_type type,
444-
FILE *out, bool write_no)
443+
static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no)
445444
{
446445
const char *str;
447446

448-
switch (type) {
447+
switch (sym->type) {
449448
case S_BOOLEAN:
450449
case S_TRISTATE:
451450
switch (sym_get_tristate_value(sym)) {
@@ -532,7 +531,7 @@ int conf_write_defconfig(const char *filename)
532531
goto next_menu;
533532
}
534533
}
535-
conf_write_symbol(sym, sym->type, out, true);
534+
conf_write_symbol(sym, out, true);
536535
}
537536
next_menu:
538537
if (menu->list != NULL) {
@@ -561,7 +560,6 @@ int conf_write(const char *name)
561560
const char *basename;
562561
const char *str;
563562
char dirname[PATH_MAX+1], tmpname[PATH_MAX+1], newname[PATH_MAX+1];
564-
enum symbol_type type;
565563
time_t now;
566564
int use_timestamp = 1;
567565
char *env;
@@ -633,14 +631,8 @@ int conf_write(const char *name)
633631
if (!(sym->flags & SYMBOL_WRITE))
634632
goto next;
635633
sym->flags &= ~SYMBOL_WRITE;
636-
type = sym->type;
637-
if (type == S_TRISTATE) {
638-
sym_calc_value(modules_sym);
639-
if (modules_sym->curr.tri == no)
640-
type = S_BOOLEAN;
641-
}
642634
/* Write config symbol to file */
643-
conf_write_symbol(sym, type, out, true);
635+
conf_write_symbol(sym, out, true);
644636
}
645637

646638
next:
@@ -833,8 +825,7 @@ int conf_write_autoconf(void)
833825
" * Automatically generated C config: don't edit\n"
834826
" * %s\n"
835827
" * %s"
836-
" */\n"
837-
"#define AUTOCONF_INCLUDED\n",
828+
" */\n",
838829
rootmenu.prompt->text, ctime(&now));
839830

840831
for_all_symbols(i, sym) {
@@ -843,7 +834,7 @@ int conf_write_autoconf(void)
843834
continue;
844835

845836
/* write symbol to config file */
846-
conf_write_symbol(sym, sym->type, out, false);
837+
conf_write_symbol(sym, out, false);
847838

848839
/* update autoconf and tristate files */
849840
switch (sym->type) {
@@ -946,7 +937,7 @@ static void randomize_choice_values(struct symbol *csym)
946937
int cnt, def;
947938

948939
/*
949-
* If choice is mod then we may have more items slected
940+
* If choice is mod then we may have more items selected
950941
* and if no then no-one.
951942
* In both cases stop.
952943
*/
@@ -1042,10 +1033,10 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
10421033

10431034
/*
10441035
* We have different type of choice blocks.
1045-
* If curr.tri equal to mod then we can select several
1036+
* If curr.tri equals to mod then we can select several
10461037
* choice symbols in one block.
10471038
* In this case we do nothing.
1048-
* If curr.tri equal yes then only one symbol can be
1039+
* If curr.tri equals yes then only one symbol can be
10491040
* selected in a choice block and we set it to yes,
10501041
* and the rest to no.
10511042
*/

‎scripts/kconfig/expr.c‎

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct expr *expr_alloc_or(struct expr *e1, struct expr *e2)
6464
return e2 ? expr_alloc_two(E_OR, e1, e2) : e1;
6565
}
6666

67-
struct expr *expr_copy(struct expr *org)
67+
struct expr *expr_copy(const struct expr *org)
6868
{
6969
struct expr *e;
7070

@@ -1013,6 +1013,48 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
10131013
#endif
10141014
}
10151015

1016+
static inline struct expr *
1017+
expr_get_leftmost_symbol(const struct expr *e)
1018+
{
1019+
1020+
if (e == NULL)
1021+
return NULL;
1022+
1023+
while (e->type != E_SYMBOL)
1024+
e = e->left.expr;
1025+
1026+
return expr_copy(e);
1027+
}
1028+
1029+
/*
1030+
* Given expression `e1' and `e2', returns the leaf of the longest
1031+
* sub-expression of `e1' not containing 'e2.
1032+
*/
1033+
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
1034+
{
1035+
struct expr *ret;
1036+
1037+
switch (e1->type) {
1038+
case E_OR:
1039+
return expr_alloc_and(
1040+
expr_simplify_unmet_dep(e1->left.expr, e2),
1041+
expr_simplify_unmet_dep(e1->right.expr, e2));
1042+
case E_AND: {
1043+
struct expr *e;
1044+
e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
1045+
e = expr_eliminate_dups(e);
1046+
ret = (!expr_eq(e, e1)) ? e1 : NULL;
1047+
expr_free(e);
1048+
break;
1049+
}
1050+
default:
1051+
ret = e1;
1052+
break;
1053+
}
1054+
1055+
return expr_get_leftmost_symbol(ret);
1056+
}
1057+
10161058
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
10171059
{
10181060
if (!e) {

‎scripts/kconfig/expr.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e
192192
struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2);
193193
struct expr *expr_alloc_and(struct expr *e1, struct expr *e2);
194194
struct expr *expr_alloc_or(struct expr *e1, struct expr *e2);
195-
struct expr *expr_copy(struct expr *org);
195+
struct expr *expr_copy(const struct expr *org);
196196
void expr_free(struct expr *e);
197197
int expr_eq(struct expr *e1, struct expr *e2);
198198
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2);
@@ -207,6 +207,7 @@ struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2);
207207
struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2);
208208
void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2);
209209
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
210+
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
210211

211212
void expr_fprint(struct expr *e, FILE *out);
212213
struct gstr; /* forward */

‎scripts/kconfig/lkc.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
static inline const char *gettext(const char *txt) { return txt; }
1515
static inline void textdomain(const char *domainname) {}
1616
static inline void bindtextdomain(const char *name, const char *dir) {}
17+
static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; }
1718
#endif
1819

1920
#ifdef __cplusplus
@@ -67,10 +68,12 @@ struct kconf_id {
6768
enum symbol_type stype;
6869
};
6970

71+
#ifdef YYDEBUG
72+
extern int zconfdebug;
73+
#endif
74+
7075
int zconfparse(void);
7176
void zconfdump(FILE *out);
72-
73-
extern int zconfdebug;
7477
void zconf_starthelp(void);
7578
FILE *zconf_fopen(const char *name);
7679
void zconf_initscan(const char *name);

‎scripts/kconfig/menu.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void menu_add_option(int token, char *arg)
203203
}
204204
}
205205

206-
static int menu_range_valid_sym(struct symbol *sym, struct symbol *sym2)
206+
static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
207207
{
208208
return sym2->type == S_INT || sym2->type == S_HEX ||
209209
(sym2->type == S_UNKNOWN && sym_string_valid(sym, sym2->name));
@@ -221,6 +221,15 @@ static void sym_check_prop(struct symbol *sym)
221221
prop_warn(prop,
222222
"default for config symbol '%s'"
223223
" must be a single symbol", sym->name);
224+
if (prop->expr->type != E_SYMBOL)
225+
break;
226+
sym2 = prop_get_symbol(prop);
227+
if (sym->type == S_HEX || sym->type == S_INT) {
228+
if (!menu_validate_number(sym, sym2))
229+
prop_warn(prop,
230+
"'%s': number is invalid",
231+
sym->name);
232+
}
224233
break;
225234
case P_SELECT:
226235
sym2 = prop_get_symbol(prop);
@@ -240,8 +249,8 @@ static void sym_check_prop(struct symbol *sym)
240249
if (sym->type != S_INT && sym->type != S_HEX)
241250
prop_warn(prop, "range is only allowed "
242251
"for int or hex symbols");
243-
if (!menu_range_valid_sym(sym, prop->expr->left.sym) ||
244-
!menu_range_valid_sym(sym, prop->expr->right.sym))
252+
if (!menu_validate_number(sym, prop->expr->left.sym) ||
253+
!menu_validate_number(sym, prop->expr->right.sym))
245254
prop_warn(prop, "range is invalid");
246255
break;
247256
default:

‎scripts/kconfig/nconf.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ search_help[] = N_(
248248
"Only relevant lines are shown.\n"
249249
"\n\n"
250250
"Search examples:\n"
251-
"Examples: USB = > find all symbols containing USB\n"
251+
"Examples: USB => find all symbols containing USB\n"
252252
" ^USB => find all symbols starting with USB\n"
253253
" USB$ => find all symbols ending with USB\n"
254254
"\n");
@@ -1266,9 +1266,13 @@ static void conf_choice(struct menu *menu)
12661266
if (child->sym == sym_get_choice_value(menu->sym))
12671267
item_make(child, ':', "<X> %s",
12681268
_(menu_get_prompt(child)));
1269-
else
1269+
else if (child->sym)
12701270
item_make(child, ':', " %s",
12711271
_(menu_get_prompt(child)));
1272+
else
1273+
item_make(child, ':', "*** %s ***",
1274+
_(menu_get_prompt(child)));
1275+
12721276
if (child->sym == active){
12731277
last_top_row = top_row(curses_menu);
12741278
selected_index = i;
@@ -1334,7 +1338,7 @@ static void conf_choice(struct menu *menu)
13341338
break;
13351339

13361340
child = item_data();
1337-
if (!child || !menu_is_visible(child))
1341+
if (!child || !menu_is_visible(child) || !child->sym)
13381342
continue;
13391343
switch (res) {
13401344
case ' ':

‎scripts/kconfig/symbol.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,16 @@ void sym_calc_value(struct symbol *sym)
351351
}
352352
calc_newval:
353353
if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
354+
struct expr *e;
355+
e = expr_simplify_unmet_dep(sym->rev_dep.expr,
356+
sym->dir_dep.expr);
354357
fprintf(stderr, "warning: (");
355-
expr_fprint(sym->rev_dep.expr, stderr);
358+
expr_fprint(e, stderr);
356359
fprintf(stderr, ") selects %s which has unmet direct dependencies (",
357360
sym->name);
358361
expr_fprint(sym->dir_dep.expr, stderr);
359362
fprintf(stderr, ")\n");
363+
expr_free(e);
360364
}
361365
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
362366
}
@@ -686,7 +690,7 @@ const char *sym_get_string_default(struct symbol *sym)
686690
switch (sym->type) {
687691
case S_BOOLEAN:
688692
case S_TRISTATE:
689-
/* The visibility imay limit the value from yes => mod */
693+
/* The visibility may limit the value from yes => mod */
690694
val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri);
691695
break;
692696
default:

0 commit comments

Comments
 (0)