All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-kbuild@vger.kernel.org,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Ingo Molnar <mingo@elte.hu>,
	zippel@linux-m68k.org
Subject: [PATCH v2] kconfig: check for select dependency errors on config load
Date: Sat, 21 Feb 2009 15:46:29 -0500 (EST)	[thread overview]
Message-ID: <alpine.DEB.2.00.0902211535440.18221@gandalf.stny.rr.com> (raw)
In-Reply-To: <alpine.DEB.2.00.0902211504200.30069@gandalf.stny.rr.com>


On Sat, 21 Feb 2009, Steven Rostedt wrote:
> On Fri, 20 Feb 2009, Randy Dunlap wrote:
> > EMBEDDED is misnamed.  It means "those who think that they know enough
> > to use all of the power of kconfig."
> > Some people spell that EXPERT etc.
> > Or it means "let me shoot myself in the foot."

> 
> Anyway, to avoid having these spit out all the time, I'll see if I can 
> make it not warn if the dependency was on EMBEDDED/EXPERT. I'll try to 
> work on it when I have time.

That was easier than I expected. Here's an updated version of the patch.

It now finds the symbol EMBEDDED, saves its state. Updates its state to 
'yes', runs the tests, resets its state back to what it was.

Now all I get from that previous config:

$ make menuconfig
scripts/kconfig/mconf arch/x86/Kconfig
.config:2561:warning: SCSI_SAS_LIBSAS selects SCSI_SAS_ATTRS which fails its dependencies!
.config:2561:warning: DRM selects I2C_ALGOBIT which fails its dependencies!

Hmm, that I2C_ALGOBIT depends on I2C_HELPER_AUTO, which looks similar to 
the EMBEDDED option. That is, Don't show this option unless this is not 
selected. I may just add a 'WHITELIST' of things that will be enabled 
during thet test.

But the SCSI_SAS_ATTRS depends on BLK_DEV_BSG which is not selected.


I also added to run the test on write as well.

But having it find the culprits will require a bit more that 5 minutes of
work. That will stay on my TODO list for now.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 830d9ea..7717926 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -310,6 +310,127 @@ load:
 	return 0;
 }
 
+static int test_deps(struct symbol *sym)
+{
+	struct property *prop;
+	struct expr *expr;
+
+	if (sym->rev_dep.tri == no)
+		return 1;
+
+	for (prop = sym->prop; prop; prop = prop->next) {
+		if (prop->type != P_PROMPT)
+			continue;
+
+		expr = prop->visible.expr;
+		if (!expr)
+			continue;
+
+		if (expr_calc_value(expr) == no)
+			return 0;
+	}
+
+	return 1;
+}
+
+void test_select(struct symbol *sym)
+{
+	struct property *prop;
+	struct expr *expr;
+
+	for (prop = sym->prop; prop; prop = prop->next) {
+		if (prop->type != P_SELECT)
+			continue;
+
+		expr = prop->expr;
+
+		if (!expr || expr->type != E_SYMBOL ||
+		    !expr->left.sym)
+			continue;
+			
+		if (test_deps(expr->left.sym))
+			continue;
+
+		conf_warning("%s selects %s which fails its dependencies!",
+			     sym->name, expr->left.sym->name);
+	}
+}
+
+void test_conf(void)
+{
+	struct symbol *sym, *embedded;
+	tristate embed_tri;
+	struct menu *menu;
+	int type;
+
+	/*
+	 * EMBEDDED is more like an "EXPERT" option. It is OK
+	 * to select it even when it does not have the proper
+	 * dependencies.
+	 *
+	 * Find  the EMBEDDED symbol.
+	 * Save its state.
+	 * Set it to 'yes'.
+	 * Run tests.
+	 * Reset the EMBEDDED symbol.
+	 */
+	embedded = sym_lookup("EMBEDDED", 0);
+	embed_tri = embedded->curr.tri;
+	embedded->curr.tri = yes;
+	
+	menu = rootmenu.list;
+	while (menu) {
+		sym = menu->sym;
+		if (!sym)
+			goto next;
+
+		if (!(sym->flags & SYMBOL_CHOICE)) {
+			sym_calc_value(sym);
+			if (!(sym->flags & SYMBOL_WRITE))
+				goto next;
+			type = sym->type;
+			if (type == S_TRISTATE) {
+				sym_calc_value(modules_sym);
+				if (modules_sym->curr.tri == no)
+					type = S_BOOLEAN;
+			}
+			switch (type) {
+			case S_BOOLEAN:
+			case S_TRISTATE:
+				switch (sym_get_tristate_value(sym)) {
+				case no:
+					break;
+				case mod:
+				case yes:
+					test_select(sym);
+					break;
+				}
+				break;
+			case S_STRING:
+			case S_HEX:
+			case S_INT:
+				break;
+			}
+		}
+
+	next:
+		if (menu->list) {
+			menu = menu->list;
+			continue;
+		}
+		if (menu->next)
+			menu = menu->next;
+		else while ((menu = menu->parent)) {
+			if (menu->next) {
+				menu = menu->next;
+				break;
+			}
+		}
+	}
+
+	embedded->curr.tri = embed_tri;
+}
+
 int conf_read(const char *name)
 {
 	struct symbol *sym, *choice_sym;
@@ -386,6 +507,7 @@ int conf_read(const char *name)
 
 	sym_add_change_count(conf_warnings || conf_unsaved);
 
+	test_conf();
 	return 0;
 }
 
@@ -550,6 +672,8 @@ int conf_write(const char *name)
 
 	sym_set_change_count(0);
 
+	test_conf();
+
 	return 0;
 }
 


  reply	other threads:[~2009-02-21 20:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20 16:34 [PATCH] tracing/markers: make markers select tracepoints Frederic Weisbecker
2009-02-20 16:59 ` Randy Dunlap
2009-02-20 17:20   ` Frederic Weisbecker
2009-02-20 17:22   ` Ingo Molnar
2009-02-20 17:29     ` Randy Dunlap
2009-02-20 17:31     ` Frederic Weisbecker
2009-02-20 17:48       ` Ingo Molnar
2009-02-20 18:56         ` Jason Baron
2009-02-21  3:15         ` Frederic Weisbecker
2009-02-21 22:04         ` Frank Ch. Eigler
2009-02-22 17:13           ` Ingo Molnar
2009-02-22 17:38             ` Frank Ch. Eigler
2009-02-23 10:13         ` Avi Kivity
2009-02-22  3:23     ` KOSAKI Motohiro
2009-02-22 11:37       ` Peter Zijlstra
2009-02-22 16:04         ` Mathieu Desnoyers
2009-02-22 19:17           ` Ingo Molnar
2009-02-23  2:47             ` Mathieu Desnoyers
2009-02-23  8:52               ` Ingo Molnar
2009-02-22 11:43     ` Peter Zijlstra
2009-02-22 12:08       ` Frank Ch. Eigler
2009-02-22 12:14         ` Peter Zijlstra
2009-02-22 12:24           ` Frank Ch. Eigler
2009-02-23 11:11             ` Peter Zijlstra
2009-02-23 15:44               ` Frank Ch. Eigler
2009-02-23 16:22                 ` Peter Zijlstra
2009-02-23 17:10                   ` Frank Ch. Eigler
2009-02-23 17:23                     ` Ingo Molnar
2009-02-24 13:01                       ` Frank Ch. Eigler
2009-02-23 17:31                     ` Steven Rostedt
2009-02-23 18:32                       ` Theodore Tso
2009-02-23 22:16                         ` Peter Zijlstra
2009-02-23 22:41                           ` Theodore Tso
2009-02-24  8:55                             ` Peter Zijlstra
2009-02-23  0:23       ` Steven Rostedt
2009-02-21  5:24   ` [PATCH][RFC] check for select dependency errors on config load Steven Rostedt
2009-02-21  5:58     ` Andrew Morton
2009-02-21  6:08     ` Andrew Morton
2009-02-21  6:20       ` Randy Dunlap
2009-02-21 20:07         ` Steven Rostedt
2009-02-21 20:46           ` Steven Rostedt [this message]
2009-02-21 20:48             ` [PATCH v2] kconfig: " Steven Rostedt
2009-02-21 21:51             ` Sam Ravnborg
2009-02-21 21:53               ` Steven Rostedt
2009-02-22 16:23     ` [PATCH][RFC] " Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.00.0902211535440.18221@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=randy.dunlap@oracle.com \
    --cc=zippel@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.