Commit d5afb482 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: refactor error messages in sym_check_print_recursive()

Improve the error messages and clean up redundant code.

[1] remove redundant next_sym->name checks

If 'next_sym' is a choice, the first 'if' block is executed. In the
subsequent 'else if' blocks, 'next_sym" is not a choice, hence
next_sym->name is not NULL.

[2] remove redundant sym->name checks

A choice is never selected or implied by anyone because it has no name
(it is syntactically impossible). If it is, sym->name is not NULL.

[3] Show the location of choice instead of "<choice>"

"part of choice <choice>" does not convey useful information. Since a
choice has no name, it is more informative to display the file name and
line number.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent d67624d8
...@@ -1107,37 +1107,37 @@ static void sym_check_print_recursive(struct symbol *last_sym) ...@@ -1107,37 +1107,37 @@ static void sym_check_print_recursive(struct symbol *last_sym)
prop->filename, prop->lineno); prop->filename, prop->lineno);
if (sym_is_choice(next_sym)) { if (sym_is_choice(next_sym)) {
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", choice = list_first_entry(&next_sym->menus, struct menu, link);
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice block at %s:%d\n",
menu->filename, menu->lineno, menu->filename, menu->lineno,
sym->name ? sym->name : "<choice>", sym->name ? sym->name : "<choice>",
next_sym->name ? next_sym->name : "<choice>"); choice->filename, choice->lineno);
} else if (stack->expr == &sym->dir_dep.expr) { } else if (stack->expr == &sym->dir_dep.expr) {
fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
prop->filename, prop->lineno, prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>", sym->name ? sym->name : "<choice>",
next_sym->name ? next_sym->name : "<choice>"); next_sym->name);
} else if (stack->expr == &sym->rev_dep.expr) { } else if (stack->expr == &sym->rev_dep.expr) {
fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
prop->filename, prop->lineno, prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>", sym->name, next_sym->name);
next_sym->name ? next_sym->name : "<choice>");
} else if (stack->expr == &sym->implied.expr) { } else if (stack->expr == &sym->implied.expr) {
fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n", fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
prop->filename, prop->lineno, prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>", sym->name, next_sym->name);
next_sym->name ? next_sym->name : "<choice>");
} else if (stack->expr) { } else if (stack->expr) {
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
prop->filename, prop->lineno, prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>", sym->name ? sym->name : "<choice>",
prop_get_type_name(prop->type), prop_get_type_name(prop->type),
next_sym->name ? next_sym->name : "<choice>"); next_sym->name);
} else { } else {
fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n", fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
prop->filename, prop->lineno, prop->filename, prop->lineno,
sym->name ? sym->name : "<choice>", sym->name ? sym->name : "<choice>",
prop_get_type_name(prop->type), prop_get_type_name(prop->type),
next_sym->name ? next_sym->name : "<choice>"); next_sym->name);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment