diff options
author | Arnaud Lacombe <lacombar@gmail.com> | 2010-09-26 16:24:08 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2010-12-21 11:59:14 -0500 |
commit | 1137c56b7420c801147e0863845c03b07554721a (patch) | |
tree | 73f1decaebc5a2825e04b30569b0a97595397360 /scripts | |
parent | ab60bd0b92ec57c98df08616b7d0664be5551eae (diff) |
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 <catalin.marinas@arm.com>
Signed-off-by: Arnaud Lacombe <lacombar@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/expr.c | 42 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 6 |
2 files changed, 47 insertions, 1 deletions
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) | |||
1013 | #endif | 1013 | #endif |
1014 | } | 1014 | } |
1015 | 1015 | ||
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 | |||
1016 | void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) | 1058 | void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) |
1017 | { | 1059 | { |
1018 | if (!e) { | 1060 | 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) | |||
351 | } | 351 | } |
352 | calc_newval: | 352 | calc_newval: |
353 | if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { | 353 | 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); | ||
354 | fprintf(stderr, "warning: ("); | 357 | fprintf(stderr, "warning: ("); |
355 | expr_fprint(sym->rev_dep.expr, stderr); | 358 | expr_fprint(e, stderr); |
356 | fprintf(stderr, ") selects %s which has unmet direct dependencies (", | 359 | fprintf(stderr, ") selects %s which has unmet direct dependencies (", |
357 | sym->name); | 360 | sym->name); |
358 | expr_fprint(sym->dir_dep.expr, stderr); | 361 | expr_fprint(sym->dir_dep.expr, stderr); |
359 | fprintf(stderr, ")\n"); | 362 | fprintf(stderr, ")\n"); |
363 | expr_free(e); | ||
360 | } | 364 | } |
361 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); | 365 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); |
362 | } | 366 | } |