* [PATCH 1/1] [RFC] kconfig: warn if an unknown symbol is selected
@ 2014-09-26 22:08 Paul Bolle
2014-09-29 14:41 ` Michal Marek
0 siblings, 1 reply; 2+ messages in thread
From: Paul Bolle @ 2014-09-26 22:08 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild, linux-kernel
A select of an unknown symbol is basically treated as a nop and is
silently skipped. This is annoying if the selected symbol contains a
typo. It can also hide the fact that a treewide symbol cleanup was only
done partially.
There are also a few cases were this might have been done on purpose.
But that anti-pattern should be discouraged. Almost all select
statements point to a known and reachable symbol. So people will likely
assume that any selected symbol is actually set. Violating that
assumption might lead to (subtle) bugs.
So let's warn when we notice a select of a symbol that is not known in
the configuration we're creating.
Rfced-by: Paul Bolle <pebolle@tiscali.nl>
---
scripts/kconfig/conf.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fef75fc756f4..de8406287531 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -446,6 +446,45 @@ static void check_conf(struct menu *menu)
check_conf(child);
}
+static void check_selects(struct menu *menu)
+{
+ struct symbol *sym, *sel;
+ struct property *prop;
+
+ while (menu) {
+ sym = menu->sym;
+
+ if (sym && !sym_is_choice(sym) &&
+ sym->type != S_UNKNOWN &&
+ sym->flags & SYMBOL_WRITE) {
+ for_all_properties(sym, prop, P_SELECT) {
+ sel = prop->expr->left.sym;
+ if (sel->type == S_UNKNOWN &&
+ expr_calc_value(prop->visible.expr) != no) {
+ fprintf(stderr, "%s:%d:warning: ",
+ prop->file->name,
+ prop->lineno);
+ fprintf(stderr,
+ "'%s' selects unknown symbol '%s'\n",
+ sym->name,
+ sel->name);
+ }
+ }
+ }
+
+ if (menu->list) {
+ menu = menu->list;
+ } else if (menu->next) {
+ menu = menu->next;
+ } else while ((menu = menu->parent)) {
+ if (menu->next) {
+ menu = menu->next;
+ break;
+ }
+ }
+ }
+}
+
static struct option long_opts[] = {
{"oldaskconfig", no_argument, NULL, oldaskconfig},
{"oldconfig", no_argument, NULL, oldconfig},
@@ -681,6 +720,8 @@ int main(int ac, char **av)
break;
}
+ check_selects(rootmenu.list);
+
if (sync_kconfig) {
/* silentoldconfig is used during the build so we shall update autoconf.
* All other commands are only used to generate a config.
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] [RFC] kconfig: warn if an unknown symbol is selected
2014-09-26 22:08 [PATCH 1/1] [RFC] kconfig: warn if an unknown symbol is selected Paul Bolle
@ 2014-09-29 14:41 ` Michal Marek
0 siblings, 0 replies; 2+ messages in thread
From: Michal Marek @ 2014-09-29 14:41 UTC (permalink / raw)
To: Paul Bolle; +Cc: Yann E. MORIN, linux-kbuild, linux-kernel
On 2014-09-27 00:08, Paul Bolle wrote:
> A select of an unknown symbol is basically treated as a nop and is
> silently skipped. This is annoying if the selected symbol contains a
> typo. It can also hide the fact that a treewide symbol cleanup was only
> done partially.
>
> There are also a few cases were this might have been done on purpose.
> But that anti-pattern should be discouraged. Almost all select
> statements point to a known and reachable symbol. So people will likely
> assume that any selected symbol is actually set. Violating that
> assumption might lead to (subtle) bugs.
>
> So let's warn when we notice a select of a symbol that is not known in
> the configuration we're creating.
>
> Rfced-by: Paul Bolle <pebolle@tiscali.nl>
I think this is a good idea, it fits well next to the already present
warning about selecting symbols with unmet dependencies. Feel free to
submit as a regular patch with
Acked-by: Michal Marek <mmarek@suse.cz>
Michal
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-29 14:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-26 22:08 [PATCH 1/1] [RFC] kconfig: warn if an unknown symbol is selected Paul Bolle
2014-09-29 14:41 ` Michal Marek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).