public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* kconfig - hex are considered decimal
@ 2008-06-29 11:51 Sam Ravnborg
  2008-06-29 21:29 ` Sam Ravnborg
  2008-06-30 13:19 ` Roman Zippel
  0 siblings, 2 replies; 8+ messages in thread
From: Sam Ravnborg @ 2008-06-29 11:51 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kbuild

Hi Roman.

I was applying an old patch from you that introduces
conf_set_all_new_symbols().

But when I tested it I noticed that all symbols
of type "hex" were saved as decimal vlaues in .config.

Sample (first line is with unmodifed kconfig):

-CONFIG_RADIO_ZOLTRIX_PORT=0x20c
+CONFIG_RADIO_ZOLTRIX_PORT=20c

I guess this has something to do with the way we
represent a hex value internally. But I have not yet
dived into it.

Can you see where it goes wrong?

I have attached two patches.
The first is the one from you and the second is the
one where I started to use the new function.

	Sam

From 23a6db63846ef5658fd2e036064f03b98ea0ecec Mon Sep 17 00:00:00 2001
From: Roman Zippel <zippel@linux-m68k.org>
Date: Tue, 6 May 2008 04:55:55 +0200
Subject: [PATCH] kconfig: set all new symbols automatically

Add conf_set_all_new_symbols() which set all symbols (which don't have a
value yet) to a specifed value.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 scripts/kconfig/confdata.c |   70 ++++++++++++++++++++++++++++++++++++++++++++
 scripts/kconfig/lkc.h      |    9 +++++
 2 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ee5fe94..0759761 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn)(void))
 {
 	conf_changed_callback = fn;
 }
+
+
+void conf_set_all_new_symbols(enum conf_def_mode mode)
+{
+	struct symbol *sym, *csym;
+	struct property *prop;
+	struct expr *e;
+	int i, cnt, def;
+
+	for_all_symbols(i, sym) {
+		if (sym_has_value(sym))
+			continue;
+		switch (sym_get_type(sym)) {
+		case S_BOOLEAN:
+		case S_TRISTATE:
+			switch (mode) {
+			case def_yes:
+				sym->def[S_DEF_USER].tri = yes;
+				break;
+			case def_mod:
+				sym->def[S_DEF_USER].tri = mod;
+				break;
+			case def_no:
+				sym->def[S_DEF_USER].tri = no;
+				break;
+			case def_random:
+				sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
+				break;
+			default:
+				continue;
+			}
+			if (!sym_is_choice(sym) || mode != def_random)
+				sym->flags |= SYMBOL_DEF_USER;
+			break;
+		default:
+			break;
+		}
+
+	}
+
+	if (modules_sym)
+		sym_calc_value(modules_sym);
+
+	if (mode != def_random)
+		return;
+
+	for_all_symbols(i, csym) {
+		if (sym_has_value(csym) || !sym_is_choice(csym))
+			continue;
+
+		sym_calc_value(csym);
+		prop = sym_get_choice_prop(csym);
+		def = -1;
+		while (1) {
+			cnt = 0;
+			expr_list_for_each_sym(prop->expr, e, sym) {
+				if (sym->visible == no)
+					continue;
+				if (def == cnt++) {
+					csym->def[S_DEF_USER].val = sym;
+					break;
+				}
+			}
+			if (def >= 0 || cnt < 2)
+				break;
+			def = (rand() % cnt) + 1;
+		}
+		csym->flags |= SYMBOL_DEF_USER;
+	}
+}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 96521cb..4a9af6f 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -42,6 +42,14 @@ extern "C" {
 #define TF_PARAM	0x0002
 #define TF_OPTION	0x0004
 
+enum conf_def_mode {
+	def_default,
+	def_yes,
+	def_mod,
+	def_no,
+	def_random
+};
+
 #define T_OPT_MODULES		1
 #define T_OPT_DEFCONFIG_LIST	2
 #define T_OPT_ENV		3
@@ -69,6 +77,7 @@ const char *conf_get_configname(void);
 char *conf_get_default_confname(void);
 void sym_set_change_count(int count);
 void sym_add_change_count(int count);
+void conf_set_all_new_symbols(enum conf_def_mode mode);
 
 /* kconfig_load.c */
 void kconfig_load(void);
-- 
1.5.4.1.143.ge7e51


diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fda6313..bd2a27e 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -76,7 +76,6 @@ static void check_stdin(void)
 static int conf_askvalue(struct symbol *sym, const char *def)
 {
 	enum symbol_type type = sym_get_type(sym);
-	tristate val;
 
 	if (!sym_has_value(sym))
 		printf(_("(NEW) "));
@@ -92,15 +91,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
 	}
 
 	switch (input_mode) {
-	case set_no:
-	case set_mod:
-	case set_yes:
-	case set_random:
-		if (sym_has_value(sym)) {
-			printf("%s\n", def);
-			return 0;
-		}
-		break;
 	case ask_new:
 	case ask_silent:
 		if (sym_has_value(sym)) {
@@ -128,52 +118,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
 	default:
 		;
 	}
-	switch (input_mode) {
-	case set_yes:
-		if (sym_tristate_within_range(sym, yes)) {
-			line[0] = 'y';
-			line[1] = '\n';
-			line[2] = 0;
-			break;
-		}
-	case set_mod:
-		if (type == S_TRISTATE) {
-			if (sym_tristate_within_range(sym, mod)) {
-				line[0] = 'm';
-				line[1] = '\n';
-				line[2] = 0;
-				break;
-			}
-		} else {
-			if (sym_tristate_within_range(sym, yes)) {
-				line[0] = 'y';
-				line[1] = '\n';
-				line[2] = 0;
-				break;
-			}
-		}
-	case set_no:
-		if (sym_tristate_within_range(sym, no)) {
-			line[0] = 'n';
-			line[1] = '\n';
-			line[2] = 0;
-			break;
-		}
-	case set_random:
-		do {
-			val = (tristate)(rand() % 3);
-		} while (!sym_tristate_within_range(sym, val));
-		switch (val) {
-		case no: line[0] = 'n'; break;
-		case mod: line[0] = 'm'; break;
-		case yes: line[0] = 'y'; break;
-		}
-		line[1] = '\n';
-		line[2] = 0;
-		break;
-	default:
-		break;
-	}
 	printf("%s", line);
 	return 1;
 }
@@ -374,16 +318,12 @@ static int conf_choice(struct menu *menu)
 			else
 				continue;
 			break;
-		case set_random:
-			if (is_new)
-				def = (rand() % cnt) + 1;
 		case set_default:
-		case set_yes:
-		case set_mod:
-		case set_no:
 			cnt = def;
 			printf("%d\n", cnt);
 			break;
+		default:
+			break;
 		}
 
 	conf_childs:
@@ -494,6 +434,43 @@ static void check_conf(struct menu *menu)
 		check_conf(child);
 }
 
+static void conf_do_update(void)
+{
+	/* Update until a loop caused no more changes */
+	do {
+		conf_cnt = 0;
+		check_conf(&rootmenu);
+	} while (conf_cnt);
+}
+
+static int conf_silent_update(void)
+{
+	const char *name;
+
+	if (conf_get_changed()) {
+		name = getenv("KCONFIG_NOSILENTUPDATE");
+		if (name && *name) {
+			fprintf(stderr,
+			_("\n*** Kernel configuration requires explicit update.\n\n"));
+			return 1;
+		}
+		conf_do_update();
+	}
+	return 0;
+}
+
+static int conf_update(void)
+{
+	rootEntry = &rootmenu;
+	conf(&rootmenu);
+	if (input_mode == ask_all) {
+		input_mode = ask_silent;
+		valid_stdin = 1;
+	}
+	conf_do_update();
+	return 0;
+}
+
 int main(int ac, char **av)
 {
 	int opt;
@@ -599,36 +576,41 @@ int main(int ac, char **av)
 	default:
 		break;
 	}
+	switch (input_mode) {
+	case set_no:
+		conf_set_all_new_symbols(def_no);
+		break;
+	case set_yes:
+		conf_set_all_new_symbols(def_yes);
+		break;
+	case set_mod:
+		conf_set_all_new_symbols(def_mod);
+		break;
+	case set_random:
+		conf_set_all_new_symbols(def_random);
+		break;
+	case ask_silent:
+		if (conf_silent_update())
+			exit(1);
+		break;
+	case ask_new:
+	case ask_all:
+	case set_default:
+		if (conf_update())
+			exit(1);
+		break;
+	}
 
-	if (input_mode != ask_silent) {
-		rootEntry = &rootmenu;
-		conf(&rootmenu);
-		if (input_mode == ask_all) {
-			input_mode = ask_silent;
-			valid_stdin = 1;
-		}
-	} else if (conf_get_changed()) {
-		name = getenv("KCONFIG_NOSILENTUPDATE");
-		if (name && *name) {
-			fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
-			return 1;
-		}
-	} else
-		goto skip_check;
-
-	do {
-		conf_cnt = 0;
-		check_conf(&rootmenu);
-	} while (conf_cnt);
-	if (conf_write(NULL)) {
+	if (conf_get_changed() && conf_write(NULL)) {
 		fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
-		return 1;
+		exit(1);
 	}
-skip_check:
+	/* ask_silent is used during the build so we shall update autoconf.
+	 * All other commands are only used to generate a config.
+	 */
 	if (input_mode == ask_silent && conf_write_autoconf()) {
 		fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
 		return 1;
 	}
-
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-06-29 11:51 kconfig - hex are considered decimal Sam Ravnborg
@ 2008-06-29 21:29 ` Sam Ravnborg
  2008-06-30 13:19 ` Roman Zippel
  1 sibling, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2008-06-29 21:29 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kbuild

On Sun, Jun 29, 2008 at 01:51:20PM +0200, Sam Ravnborg wrote:
> Hi Roman.
> 
> I was applying an old patch from you that introduces
> conf_set_all_new_symbols().
> 
> But when I tested it I noticed that all symbols
> of type "hex" were saved as decimal vlaues in .config.
> 
> Sample (first line is with unmodifed kconfig):
> 
> -CONFIG_RADIO_ZOLTRIX_PORT=0x20c
> +CONFIG_RADIO_ZOLTRIX_PORT=20c
> 
> I guess this has something to do with the way we
> represent a hex value internally. But I have not yet
> dived into it.
> 
> Can you see where it goes wrong?

This seems to be the right fix.

	Sam

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 0759761..6f39c80 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -510,7 +510,7 @@ int conf_write(const char *name)
 			case S_HEX:
 				str = sym_get_string_value(sym);
 				if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
-					fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
+					fprintf(out, "CONFIG_%s=0x%s\n", sym->name, str);
 					break;
 				}
 			case S_INT:

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-06-29 11:51 kconfig - hex are considered decimal Sam Ravnborg
  2008-06-29 21:29 ` Sam Ravnborg
@ 2008-06-30 13:19 ` Roman Zippel
  2008-06-30 20:40   ` Sam Ravnborg
  1 sibling, 1 reply; 8+ messages in thread
From: Roman Zippel @ 2008-06-30 13:19 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kbuild

Hi,

On Sun, 29 Jun 2008, Sam Ravnborg wrote:

> Sample (first line is with unmodifed kconfig):
> 
> -CONFIG_RADIO_ZOLTRIX_PORT=0x20c
> +CONFIG_RADIO_ZOLTRIX_PORT=20c
> 
> I guess this has something to do with the way we
> represent a hex value internally. But I have not yet
> dived into it.
> 
> Can you see where it goes wrong?

It's not really wrong, it's a valid value there. Only if it's saved like 
this in the header file, it would be wrong.
I noticed that during testing too, that value is coming liking that 
directly from the Kconfig file. The real fix would be to deprecate hex 
values without prefix and automatically adding the prefix where needed 
(currently loading of Kconfig/.config).
I though about making it more consistent, but it's not really a pressing 
issue, so I left it as is for now.

bye, Roman

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-06-30 13:19 ` Roman Zippel
@ 2008-06-30 20:40   ` Sam Ravnborg
  2008-06-30 21:59     ` Roman Zippel
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2008-06-30 20:40 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kbuild

On Mon, Jun 30, 2008 at 03:19:09PM +0200, Roman Zippel wrote:
> Hi,
> 
> On Sun, 29 Jun 2008, Sam Ravnborg wrote:
> 
> > Sample (first line is with unmodifed kconfig):
> > 
> > -CONFIG_RADIO_ZOLTRIX_PORT=0x20c
> > +CONFIG_RADIO_ZOLTRIX_PORT=20c
> > 
> > I guess this has something to do with the way we
> > represent a hex value internally. But I have not yet
> > dived into it.
> > 
> > Can you see where it goes wrong?
> 
> It's not really wrong, it's a valid value there. Only if it's saved like 
> this in the header file, it would be wrong.
> I noticed that during testing too, that value is coming liking that 
> directly from the Kconfig file. The real fix would be to deprecate hex 
> values without prefix and automatically adding the prefix where needed 
> (currently loading of Kconfig/.config).
> I though about making it more consistent, but it's not really a pressing 
> issue, so I left it as is for now.

For now I added this patch (for previous mail).
This makes the configs equal so they can be compared.

	Sam

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 0759761..6f39c80 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -510,7 +510,7 @@ int conf_write(const char *name)
                        case S_HEX:
                                str = sym_get_string_value(sym);
                                if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) {
-                                       fprintf(out, "CONFIG_%s=%s\n", sym->name, str);
+                                       fprintf(out, "CONFIG_%s=0x%s\n", sym->name, str);
                                        break;
                                }
                        case S_INT:


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-06-30 20:40   ` Sam Ravnborg
@ 2008-06-30 21:59     ` Roman Zippel
  2008-07-01  6:12       ` Sam Ravnborg
  0 siblings, 1 reply; 8+ messages in thread
From: Roman Zippel @ 2008-06-30 21:59 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kbuild

Hi,

On Mon, 30 Jun 2008, Sam Ravnborg wrote:

> For now I added this patch (for previous mail).
> This makes the configs equal so they can be compared.

Did you try changing and saving that hex value?
You need a similiar logic as used for saving the header file.
Why is it a problem, that needs immediate fixing anyway?

bye, Roman


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-06-30 21:59     ` Roman Zippel
@ 2008-07-01  6:12       ` Sam Ravnborg
  2008-07-02 12:39         ` Roman Zippel
  0 siblings, 1 reply; 8+ messages in thread
From: Sam Ravnborg @ 2008-07-01  6:12 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kbuild

On Mon, Jun 30, 2008 at 11:59:42PM +0200, Roman Zippel wrote:
> Hi,
> 
> On Mon, 30 Jun 2008, Sam Ravnborg wrote:
> 
> > For now I added this patch (for previous mail).
> > This makes the configs equal so they can be compared.
> 
> Did you try changing and saving that hex value?
Yes.
- When changing I see the 0x prefix - which I consider OK for hex values
- When saving I see the 0x prefix in autoconf.h + .config

> You need a similiar logic as used for saving the header file.
> Why is it a problem, that needs immediate fixing anyway?

To keep difference minimal for .config produced by 
old style 'all*config' and new style 'all*config'.

See patches where kconfig start to use the new
method for 'all*config' targets - they are cc:ed to you
and available on linux-kbuild.
I simply started to use conf_set_all_new_symbols() and
as a result I could simplify conf.c.

And things got so simple that I dropped the patches
introducing aconf.c.

Yet TODO:

-> Give Redhat's nonint_oldconfig a closer look and see
   how to integrate this functionality
-> Give Andres Salomon patches a second look and see how to
   integrate the functionality he requires

It it does not turn out to be simple I will lilely postpone it
until I have moved.

	Sam

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-07-01  6:12       ` Sam Ravnborg
@ 2008-07-02 12:39         ` Roman Zippel
  2008-07-06 21:28           ` Sam Ravnborg
  0 siblings, 1 reply; 8+ messages in thread
From: Roman Zippel @ 2008-07-02 12:39 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux-kbuild

Hi,

On Tue, 1 Jul 2008, Sam Ravnborg wrote:

> - When changing I see the 0x prefix - which I consider OK for hex values
> - When saving I see the 0x prefix in autoconf.h + .config

I disagree with the proposed patch. It only makes cosmetical changes, but 
it doesn't fix the current inconsistenties. Either we do it properly as in 
the patch below or I'd rather keep it as is.
The patch checks the default values more strictly, I'm open to opinions 
whether that warning is useful or maybe just check that hex values have 
the 0x prefix.

> See patches where kconfig start to use the new
> method for 'all*config' targets - they are cc:ed to you
> and available on linux-kbuild.
> I simply started to use conf_set_all_new_symbols() and
> as a result I could simplify conf.c.
> 
> And things got so simple that I dropped the patches
> introducing aconf.c.

I'd actually prefer to move everything noninteractive out of conf.c, as 
this would be the right place for this:

> -> Give Redhat's nonint_oldconfig a closer look and see
>    how to integrate this functionality

This should be pretty much do it:

	for_all_symbols(i, sym) {
		sym_calc_value(sym);
		if (sym->flags & SYMBOL_WRITE && !sym_has_value(sym))
			printf(...);
	}

The point is that this has nothing to do with what's already in conf.c, 
this should be a separate utility for all noninteractive kconfig jobs.

bye, Roman


[PATCH] normalize int/hex values

Introduce a new strdup_type() which normalizes the input value, so that
all symbol values are properly formatted.
Check the values of defaults a bit more careful, so that their are
either proper constants or other symbols of the same type.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>

---
 arch/x86/Kconfig            |    4 ++--
 drivers/media/radio/Kconfig |   16 ++++++++--------
 drivers/mtd/devices/Kconfig |    3 +--
 drivers/mtd/maps/Kconfig    |    2 +-
 scripts/kconfig/confdata.c  |    2 +-
 scripts/kconfig/lkc.h       |    2 ++
 scripts/kconfig/menu.c      |   41 ++++++++++++++++++++++++++++++++++++-----
 scripts/kconfig/util.c      |   16 ++++++++++++++++
 sound/oss/Kconfig           |   10 +++++-----
 9 files changed, 72 insertions(+), 24 deletions(-)

Index: linux-2.6/scripts/kconfig/confdata.c
===================================================================
--- linux-2.6.orig/scripts/kconfig/confdata.c
+++ linux-2.6/scripts/kconfig/confdata.c
@@ -132,7 +132,7 @@ static int conf_set_sym_val(struct symbo
 	case S_HEX:
 	done:
 		if (sym_string_valid(sym, p)) {
-			sym->def[def].val = strdup(p);
+			sym->def[def].val = strdup_type(p, sym->type);
 			sym->flags |= def_flags;
 		} else {
 			conf_warning("symbol value '%s' invalid for %s", p, sym->name);
Index: linux-2.6/scripts/kconfig/lkc.h
===================================================================
--- linux-2.6.orig/scripts/kconfig/lkc.h
+++ linux-2.6/scripts/kconfig/lkc.h
@@ -113,6 +113,8 @@ void str_append(struct gstr *gs, const c
 void str_printf(struct gstr *gs, const char *fmt, ...);
 const char *str_get(struct gstr *gs);
 
+char *strdup_type(const char *str, int type);
+
 /* symbol.c */
 extern struct expr *sym_env_list;
 
Index: linux-2.6/scripts/kconfig/menu.c
===================================================================
--- linux-2.6.orig/scripts/kconfig/menu.c
+++ linux-2.6/scripts/kconfig/menu.c
@@ -187,15 +187,46 @@ static int menu_range_valid_sym(struct s
 void sym_check_prop(struct symbol *sym)
 {
 	struct property *prop;
-	struct symbol *sym2;
+	struct symbol *sym2, *def_sym;
+	char *str;
+
 	for (prop = sym->prop; prop; prop = prop->next) {
 		switch (prop->type) {
 		case P_DEFAULT:
-			if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
-			    prop->expr->type != E_SYMBOL)
+			if (sym->type != S_STRING && sym->type != S_INT &&
+			    sym->type != S_HEX)
+				break;
+			if (prop->expr->type != E_SYMBOL) {
 				prop_warn(prop,
-				    "default for config symbol '%'"
-				    " must be a single symbol", sym->name);
+					"default for config symbol '%s'"
+					" must be a single symbol", sym->name);
+				break;
+			}
+			def_sym = prop->expr->left.sym;
+			if (def_sym->type == sym->type)
+				/* default is a dynamic value */
+				break;
+			if (def_sym->type != S_UNKNOWN) {
+				prop_warn(prop,
+					"default for config symbol '%s'"
+					" has the wrong type (%s)", sym->name,
+					sym_type_name(def_sym->type));
+				break;
+			}
+			if (!sym_string_valid(sym, def_sym->name)) {
+				prop_warn(prop,
+					"default for config symbol '%s'"
+					" is not valid", sym->name);
+				break;
+			}
+			str = strdup_type(def_sym->name, sym->type);
+			if (strcmp(str, def_sym->name)) {
+				prop_warn(prop,
+					"default for config symbol '%s'"
+					" should be %s", sym->name, str);
+				prop->expr->left.sym = sym_lookup(str, SYMBOL_CONST);
+			}
+			free(str);
 			break;
 		case P_SELECT:
 			sym2 = prop_get_symbol(prop);
Index: linux-2.6/scripts/kconfig/util.c
===================================================================
--- linux-2.6.orig/scripts/kconfig/util.c
+++ linux-2.6/scripts/kconfig/util.c
@@ -131,3 +131,19 @@ const char *str_get(struct gstr *gs)
 	return gs->s;
 }
 
+/* duplicate str, but normalize any number according to the symbol type */
+char *strdup_type(const char *str, int type)
+{
+	char buf[64];
+
+	if (type == S_STRING)
+		return strdup(str);
+	if (type == S_HEX) {
+		unsigned int val = strtoul(str, NULL, 16);
+		sprintf(buf, "%#x", val);
+	} else {
+		int val = strtol(str, NULL, 10);
+		sprintf(buf, "%d", val);
+	}
+	return strdup(buf);
+}
Index: linux-2.6/arch/x86/Kconfig
===================================================================
--- linux-2.6.orig/arch/x86/Kconfig
+++ linux-2.6/arch/x86/Kconfig
@@ -885,11 +885,11 @@ endchoice
 
 config PAGE_OFFSET
 	hex
-	default 0xB0000000 if VMSPLIT_3G_OPT
+	default 0xb0000000 if VMSPLIT_3G_OPT
 	default 0x80000000 if VMSPLIT_2G
 	default 0x78000000 if VMSPLIT_2G_OPT
 	default 0x40000000 if VMSPLIT_1G
-	default 0xC0000000
+	default 0xc0000000
 	depends on X86_32
 
 config HIGHMEM
Index: linux-2.6/drivers/media/radio/Kconfig
===================================================================
--- linux-2.6.orig/drivers/media/radio/Kconfig
+++ linux-2.6/drivers/media/radio/Kconfig
@@ -58,7 +58,7 @@ config RADIO_RTRACK
 config RADIO_RTRACK_PORT
 	hex "RadioTrack i/o port (0x20f or 0x30f)"
 	depends on RADIO_RTRACK=y
-	default "20f"
+	default "0x20f"
 	help
 	  Enter either 0x30f or 0x20f here.  The card default is 0x30f, if you
 	  haven't changed the jumper setting on the card.
@@ -81,7 +81,7 @@ config RADIO_RTRACK2
 config RADIO_RTRACK2_PORT
 	hex "RadioTrack II i/o port (0x20c or 0x30c)"
 	depends on RADIO_RTRACK2=y
-	default "30c"
+	default "0x30c"
 	help
 	  Enter either 0x30c or 0x20c here.  The card default is 0x30c, if you
 	  haven't changed the jumper setting on the card.
@@ -104,7 +104,7 @@ config RADIO_AZTECH
 config RADIO_AZTECH_PORT
 	hex "Aztech/Packard Bell I/O port (0x350 or 0x358)"
 	depends on RADIO_AZTECH=y
-	default "350"
+	default "0x350"
 	help
 	  Enter either 0x350 or 0x358 here.  The card default is 0x350, if you
 	  haven't changed the setting of jumper JP3 on the card.  Removing the
@@ -133,7 +133,7 @@ config RADIO_GEMTEK
 config RADIO_GEMTEK_PORT
 	hex "Fixed I/O port (0x20c, 0x30c, 0x24c, 0x34c, 0c24c or 0x28c)"
 	depends on RADIO_GEMTEK=y
-	default "34c"
+	default "0x34c"
 	help
 	  Enter either 0x20c, 0x30c, 0x24c or 0x34c here. The card default is
 	  0x34c, if you haven't changed the jumper setting on the card. On
@@ -250,7 +250,7 @@ config RADIO_TERRATEC
 config RADIO_TERRATEC_PORT
 	hex "Terratec i/o port (normally 0x590)"
 	depends on RADIO_TERRATEC=y
-	default "590"
+	default "0x590"
 	help
 	  Fill in the I/O port of your TerraTec FM radio card. If unsure, go
 	  with the default.
@@ -268,7 +268,7 @@ config RADIO_TRUST
 config RADIO_TRUST_PORT
 	hex "Trust i/o port (usually 0x350 or 0x358)"
 	depends on RADIO_TRUST=y
-	default "350"
+	default "0x350"
 	help
 	  Enter the I/O port of your Trust FM radio card. If unsure, try the
 	  values "0x350" or "0x358".
@@ -301,7 +301,7 @@ config RADIO_TYPHOON_PROC_FS
 config RADIO_TYPHOON_PORT
 	hex "Typhoon I/O port (0x316 or 0x336)"
 	depends on RADIO_TYPHOON=y
-	default "316"
+	default "0x316"
 	help
 	  Enter the I/O port of your Typhoon or EcoRadio radio card.
 
@@ -335,7 +335,7 @@ config RADIO_ZOLTRIX
 config RADIO_ZOLTRIX_PORT
 	hex "ZOLTRIX I/O port (0x20c or 0x30c)"
 	depends on RADIO_ZOLTRIX=y
-	default "20c"
+	default "0x20c"
 	help
 	  Enter the I/O port of your Zoltrix radio card.
 
Index: linux-2.6/drivers/mtd/devices/Kconfig
===================================================================
--- linux-2.6.orig/drivers/mtd/devices/Kconfig
+++ linux-2.6/drivers/mtd/devices/Kconfig
@@ -240,8 +240,7 @@ config MTD_DOCPROBE_ADVANCED
 config MTD_DOCPROBE_ADDRESS
 	hex "Physical address of DiskOnChip" if MTD_DOCPROBE_ADVANCED
 	depends on MTD_DOCPROBE
-	default "0x0000" if MTD_DOCPROBE_ADVANCED
-	default "0" if !MTD_DOCPROBE_ADVANCED
+	default "0"
 	---help---
 	  By default, the probe for DiskOnChip devices will look for a
 	  DiskOnChip at every multiple of 0x2000 between 0xC8000 and 0xEE000.
Index: linux-2.6/drivers/mtd/maps/Kconfig
===================================================================
--- linux-2.6.orig/drivers/mtd/maps/Kconfig
+++ linux-2.6/drivers/mtd/maps/Kconfig
@@ -92,7 +92,7 @@ endchoice
 
 config MSP_FLASH_MAP_LIMIT
 	hex
-	default "0x02000000"
+	default "0x2000000"
 	depends on MSP_FLASH_MAP_LIMIT_32M
 
 config MTD_PMC_MSP_RAMROOT
Index: linux-2.6/sound/oss/Kconfig
===================================================================
--- linux-2.6.orig/sound/oss/Kconfig
+++ linux-2.6/sound/oss/Kconfig
@@ -129,7 +129,7 @@ config MSNDCLAS_IRQ
 config MSNDCLAS_MEM
 	hex "MSND Classic memory B0000, C8000, D0000, D8000, E0000, E8000"
 	depends on SOUND_MSNDCLAS=y
-	default "D0000"
+	default "0xd0000"
 	help
 	  Memory-mapped I/O base address for the MultiSound Classic and
 	  related cards.
@@ -137,7 +137,7 @@ config MSNDCLAS_MEM
 config MSNDCLAS_IO
 	hex "MSND Classic I/O 210, 220, 230, 240, 250, 260, 290, 3E0"
 	depends on SOUND_MSNDCLAS=y
-	default "290"
+	default "0x290"
 	help
 	  I/O port address for the MultiSound Classic and related cards.
 
@@ -192,7 +192,7 @@ config MSNDPIN_IRQ
 config MSNDPIN_MEM
 	hex "MSND Pinnacle memory B0000, C8000, D0000, D8000, E0000, E8000"
 	depends on SOUND_MSNDPIN=y
-	default "D0000"
+	default "0xd0000"
 	help
 	  Memory-mapped I/O base address for the primary synthesizer on
 	  MultiSound Pinnacle and Fiji sound cards.
@@ -200,7 +200,7 @@ config MSNDPIN_MEM
 config MSNDPIN_IO
 	hex "MSND Pinnacle I/O 210, 220, 230, 240, 250, 260, 290, 3E0"
 	depends on SOUND_MSNDPIN=y
-	default "290"
+	default "0x290"
 	help
 	  Memory-mapped I/O base address for the primary synthesizer on
 	  MultiSound Pinnacle and Fiji sound cards.
@@ -234,7 +234,7 @@ comment "MSND Pinnacle DSP section will 
 config MSNDPIN_CFG
 	hex "MSND Pinnacle config port 250,260,270"
 	depends on MSNDPIN_NONPNP
-	default "250"
+	default "0x250"
 	help
 	  This is the port which the Pinnacle and Fiji uses to configure the
 	  card's resources when not in PnP mode. If your card is in PnP mode,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: kconfig - hex are considered decimal
  2008-07-02 12:39         ` Roman Zippel
@ 2008-07-06 21:28           ` Sam Ravnborg
  0 siblings, 0 replies; 8+ messages in thread
From: Sam Ravnborg @ 2008-07-06 21:28 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kbuild

On Wed, Jul 02, 2008 at 02:39:08PM +0200, Roman Zippel wrote:
> Hi,
> 
> On Tue, 1 Jul 2008, Sam Ravnborg wrote:
> 
> > - When changing I see the 0x prefix - which I consider OK for hex values
> > - When saving I see the 0x prefix in autoconf.h + .config
> 
> I disagree with the proposed patch. It only makes cosmetical changes, but 
> it doesn't fix the current inconsistenties. Either we do it properly as in 
> the patch below or I'd rather keep it as is.
> The patch checks the default values more strictly, I'm open to opinions 
> whether that warning is useful or maybe just check that hex values have 
> the 0x prefix.
Thanks - I divided your patch up in two.
First one that adds the new checks
And the second that fixes the warnings
> 
> > See patches where kconfig start to use the new
> > method for 'all*config' targets - they are cc:ed to you
> > and available on linux-kbuild.
> > I simply started to use conf_set_all_new_symbols() and
> > as a result I could simplify conf.c.
> > 
> > And things got so simple that I dropped the patches
> > introducing aconf.c.
> 
> I'd actually prefer to move everything noninteractive out of conf.c, as 
> this would be the right place for this:
> 
> > -> Give Redhat's nonint_oldconfig a closer look and see
> >    how to integrate this functionality
> 
> This should be pretty much do it:
> 
> 	for_all_symbols(i, sym) {
> 		sym_calc_value(sym);
> 		if (sym->flags & SYMBOL_WRITE && !sym_has_value(sym))
> 			printf(...);
> 	}
> 
> The point is that this has nothing to do with what's already in conf.c, 
> this should be a separate utility for all noninteractive kconfig jobs.

I do not disagree with you here. But for now it was just more
natural to add it where I deleted the other stuff.
I will move it to a separate .c file later.

	Sam

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-07-06 21:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-29 11:51 kconfig - hex are considered decimal Sam Ravnborg
2008-06-29 21:29 ` Sam Ravnborg
2008-06-30 13:19 ` Roman Zippel
2008-06-30 20:40   ` Sam Ravnborg
2008-06-30 21:59     ` Roman Zippel
2008-07-01  6:12       ` Sam Ravnborg
2008-07-02 12:39         ` Roman Zippel
2008-07-06 21:28           ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox