Skip to content

Commit d5afb48

Browse files
committed
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: Masahiro Yamada <[email protected]>
1 parent d67624d commit d5afb48

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

scripts/kconfig/symbol.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,37 +1107,37 @@ static void sym_check_print_recursive(struct symbol *last_sym)
11071107
prop->filename, prop->lineno);
11081108

11091109
if (sym_is_choice(next_sym)) {
1110-
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n",
1110+
choice = list_first_entry(&next_sym->menus, struct menu, link);
1111+
1112+
fprintf(stderr, "%s:%d:\tsymbol %s is part of choice block at %s:%d\n",
11111113
menu->filename, menu->lineno,
11121114
sym->name ? sym->name : "<choice>",
1113-
next_sym->name ? next_sym->name : "<choice>");
1115+
choice->filename, choice->lineno);
11141116
} else if (stack->expr == &sym->dir_dep.expr) {
11151117
fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n",
11161118
prop->filename, prop->lineno,
11171119
sym->name ? sym->name : "<choice>",
1118-
next_sym->name ? next_sym->name : "<choice>");
1120+
next_sym->name);
11191121
} else if (stack->expr == &sym->rev_dep.expr) {
11201122
fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n",
11211123
prop->filename, prop->lineno,
1122-
sym->name ? sym->name : "<choice>",
1123-
next_sym->name ? next_sym->name : "<choice>");
1124+
sym->name, next_sym->name);
11241125
} else if (stack->expr == &sym->implied.expr) {
11251126
fprintf(stderr, "%s:%d:\tsymbol %s is implied by %s\n",
11261127
prop->filename, prop->lineno,
1127-
sym->name ? sym->name : "<choice>",
1128-
next_sym->name ? next_sym->name : "<choice>");
1128+
sym->name, next_sym->name);
11291129
} else if (stack->expr) {
11301130
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
11311131
prop->filename, prop->lineno,
11321132
sym->name ? sym->name : "<choice>",
11331133
prop_get_type_name(prop->type),
1134-
next_sym->name ? next_sym->name : "<choice>");
1134+
next_sym->name);
11351135
} else {
11361136
fprintf(stderr, "%s:%d:\tsymbol %s %s is visible depending on %s\n",
11371137
prop->filename, prop->lineno,
11381138
sym->name ? sym->name : "<choice>",
11391139
prop_get_type_name(prop->type),
1140-
next_sym->name ? next_sym->name : "<choice>");
1140+
next_sym->name);
11411141
}
11421142
}
11431143

0 commit comments

Comments
 (0)