Skip to contentSkip to conversation

kconfig: fix missing "0x" prefix from S_HEX symbol in autoconf.h

PATCH In review Arnaud Lacombe 4 participants 5 messages Jul 14, 2011 – Jul 18, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: fix missing "0x" prefix from S_HEX symbol in autoconf.h

The specialized printer for headers (espectially autoconf.h) is missing fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not warn for such missing prefix, this code is needed. Fix this.

In the same time, fix some nits in `header_print_symbol()'.

Cc Randy Dunlap <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>

(Somehow-)Reported-by: Randy Dunlap <[email protected]>

---
 scripts/kconfig/confdata.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
scripts/kconfig/confdata.c +21 -5
index be6952c..df629ec 100644
@@ -487,27 +487,43 @@ static struct conf_printer kconfig_printer_cb =
 static void
 header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
 {
-	const char *suffix = "";
 
 	switch (sym->type) {
 	case S_BOOLEAN:
-	case S_TRISTATE:
+	case S_TRISTATE: {
+		const char *suffix = "";
+
 		switch (*value) {
 		case 'n':
 			return;
 		case 'm':
 			suffix = "_MODULE";
-			/* FALLTHROUGH */
+			/* fall through */
 		default:
 			value = "1";
 		}
+		fprintf(fp, "#define %s%s%s %s\n",
+		    CONFIG_, sym->name, suffix, value);
+		break;
+	}
+	case S_HEX: {
+		const char *prefix = "";
+
+		if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
+			prefix = "0x";
+		fprintf(fp, "#define %s%s %s%s\n",
+		    CONFIG_, sym->name, prefix, value);
+		break;
+	}
+	case S_STRING:
+	case S_INT:
+		fprintf(fp, "#define %s%s %s\n",
+		    CONFIG_, sym->name, value);
 		break;
 	default:
 		break;
 	}
 
-	fprintf(fp, "#define %s%s%s %s\n",
-	    CONFIG_, sym->name, suffix, value);
 }
 
 static void
Signature · 1 line
1.7.3.4.574.g608b.dirty
Acked-by on v1 1/1
#1 lore raw

Em 14-07-2011 16:31, Arnaud Lacombe escreveu:

Quoted 6 lines

The specialized printer for headers (espectially autoconf.h) is missing fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not warn for such missing prefix, this code is needed. Fix this.

In the same time, fix some nits in `header_print_symbol()'.

Quoted 7 lines
Cc Randy Dunlap <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>

(Somehow-)Reported-by: Randy Dunlap <[email protected]>

Patch looks good for me.

Feel free to add my ack, if you want.

Quoted 58 lines
---
 scripts/kconfig/confdata.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
scripts/kconfig/confdata.c +21 -5
index be6952c..df629ec 100644
@@ -487,27 +487,43 @@ static struct conf_printer kconfig_printer_cb =
 static void
 header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
 {
-	const char *suffix = "";
 
 	switch (sym->type) {
 	case S_BOOLEAN:
-	case S_TRISTATE:
+	case S_TRISTATE: {
+		const char *suffix = "";
+
 		switch (*value) {
 		case 'n':
 			return;
 		case 'm':
 			suffix = "_MODULE";
-			/* FALLTHROUGH */
+			/* fall through */
 		default:
 			value = "1";
 		}
+		fprintf(fp, "#define %s%s%s %s\n",
+		    CONFIG_, sym->name, suffix, value);
+		break;
+	}
+	case S_HEX: {
+		const char *prefix = "";
+
+		if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
+			prefix = "0x";
+		fprintf(fp, "#define %s%s %s%s\n",
+		    CONFIG_, sym->name, prefix, value);
+		break;
+	}
+	case S_STRING:
+	case S_INT:
+		fprintf(fp, "#define %s%s %s\n",
+		    CONFIG_, sym->name, value);
 		break;
 	default:
 		break;
 	}
 
-	fprintf(fp, "#define %s%s%s %s\n",
-	    CONFIG_, sym->name, suffix, value);
 }
 
 static void
Acked-by on v1 1/1
#2 lore raw
In reply to Arnaud Lacombe
Quoted 11 lines · On Thu, 14 Jul 2011 15:31:07 -0400 Arnaud Lacombe wrote:

The specialized printer for headers (espectially autoconf.h) is missing fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not warn for such missing prefix, this code is needed. Fix this.

In the same time, fix some nits in `header_print_symbol()'.

Cc Randy Dunlap <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>

(Somehow-)Reported-by: Randy Dunlap <[email protected]>

http://marc.info/?l=linux-next&m=130981163121463&w=2

Thanks.

Quoted 63 lines
---
 scripts/kconfig/confdata.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)
scripts/kconfig/confdata.c +21 -5
index be6952c..df629ec 100644
@@ -487,27 +487,43 @@ static struct conf_printer kconfig_printer_cb =
 static void
 header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg)
 {
-	const char *suffix = "";
 
 	switch (sym->type) {
 	case S_BOOLEAN:
-	case S_TRISTATE:
+	case S_TRISTATE: {
+		const char *suffix = "";
+
 		switch (*value) {
 		case 'n':
 			return;
 		case 'm':
 			suffix = "_MODULE";
-			/* FALLTHROUGH */
+			/* fall through */
 		default:
 			value = "1";
 		}
+		fprintf(fp, "#define %s%s%s %s\n",
+		    CONFIG_, sym->name, suffix, value);
+		break;
+	}
+	case S_HEX: {
+		const char *prefix = "";
+
+		if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X'))
+			prefix = "0x";
+		fprintf(fp, "#define %s%s %s%s\n",
+		    CONFIG_, sym->name, prefix, value);
+		break;
+	}
+	case S_STRING:
+	case S_INT:
+		fprintf(fp, "#define %s%s %s\n",
+		    CONFIG_, sym->name, value);
 		break;
 	default:
 		break;
 	}
 
-	fprintf(fp, "#define %s%s%s %s\n",
-	    CONFIG_, sym->name, suffix, value);
 }
 
 static void
Signature · 1 line
1.7.3.4.574.g608b.dirty

---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

#3 lore raw
In reply to Arnaud Lacombe
Quoted 6 lines · Arnaud Lacombe

The specialized printer for headers (espectially autoconf.h) is missing fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not warn for such missing prefix, this code is needed. Fix this.

In the same time, fix some nits in `header_print_symbol()'.

Quoted 7 lines
Cc Randy Dunlap <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>

(Somehow-)Reported-by: Randy Dunlap <[email protected]>

Thanks, applied kbuild-2.6.git#kconfig. It did actually compare the kconfig generated files after your previous patch, but I only compared defconfig and it didn't trigger this bug.

Michal

#4 lore raw

Hi,

Quoted 10 lines · Michal Marek
Quoted 9 lines · Arnaud Lacombe

The specialized printer for headers (espectially autoconf.h) is missing fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not warn for such missing prefix, this code is needed. Fix this.

In the same time, fix some nits in `header_print_symbol()'.

Cc Randy Dunlap <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Quoted 9 lines
Quoted 4 lines

(Somehow-)Reported-by: Randy Dunlap <[email protected]>

Thanks, applied kbuild-2.6.git#kconfig. It did actually compare the kconfig generated files after your previous patch, but I only compared defconfig and it didn't trigger this bug.

this is why kconfig _needs_ a regression testsuite, not to rely on any existing configuration or syntax which may only be used in the corners of dark architecture. :-)

I'm more or less working on that.

- Arnaud