linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] pedantic correctness cleanup for conf.c in scripts/kconfig/ .
@ 2005-01-03 23:35 Jesper Juhl
  2005-01-05 12:26 ` Roman Zippel
  0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2005-01-03 23:35 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kernel


Hi, 

Tiny, pedantic patch for scripts/kconfig/conf.c
'line' is an array of signed chars, so lets stuff chars into it, not ints.
Doesn't make any actual difference, just feels nicer ;)


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>

diff -up linux-2.6.10-bk6-orig/scripts/kconfig/conf.c linux-2.6.10-bk6/scripts/kconfig/conf.c
--- linux-2.6.10-bk6-orig/scripts/kconfig/conf.c	2004-12-24 22:35:28.000000000 +0100
+++ linux-2.6.10-bk6/scripts/kconfig/conf.c	2005-01-04 00:30:02.000000000 +0100
@@ -72,12 +72,12 @@ static void conf_askvalue(struct symbol 
 		printf("(NEW) ");
 
 	line[0] = '\n';
-	line[1] = 0;
+	line[1] = '\0';
 
 	if (!sym_is_changable(sym)) {
 		printf("%s\n", def);
 		line[0] = '\n';
-		line[1] = 0;
+		line[1] = '\0';
 		return;
 	}
 
@@ -114,7 +114,7 @@ static void conf_askvalue(struct symbol 
 		if (sym_tristate_within_range(sym, yes)) {
 			line[0] = 'y';
 			line[1] = '\n';
-			line[2] = 0;
+			line[2] = '\0';
 			break;
 		}
 	case set_mod:
@@ -122,14 +122,14 @@ static void conf_askvalue(struct symbol 
 			if (sym_tristate_within_range(sym, mod)) {
 				line[0] = 'm';
 				line[1] = '\n';
-				line[2] = 0;
+				line[2] = '\0';
 				break;
 			}
 		} else {
 			if (sym_tristate_within_range(sym, yes)) {
 				line[0] = 'y';
 				line[1] = '\n';
-				line[2] = 0;
+				line[2] = '\0';
 				break;
 			}
 		}
@@ -137,7 +137,7 @@ static void conf_askvalue(struct symbol 
 		if (sym_tristate_within_range(sym, no)) {
 			line[0] = 'n';
 			line[1] = '\n';
-			line[2] = 0;
+			line[2] = '\0';
 			break;
 		}
 	case set_random:
@@ -150,7 +150,7 @@ static void conf_askvalue(struct symbol 
 		case yes: line[0] = 'y'; break;
 		}
 		line[1] = '\n';
-		line[2] = 0;
+		line[2] = '\0';
 		break;
 	default:
 		break;
@@ -184,7 +184,7 @@ int conf_string(struct menu *menu)
 				break;
 			}
 		default:
-			line[strlen(line)-1] = 0;
+			line[strlen(line)-1] = '\0';
 			def = line;
 		}
 		if (def && sym_set_string_value(sym, def))
@@ -248,7 +248,7 @@ static int conf_sym(struct menu *menu)
 			if (!line[1] || !strcmp(&line[1], "es"))
 				break;
 			continue;
-		case 0:
+		case '\0':
 			newval = oldval;
 			break;
 		case '?':
@@ -305,8 +305,8 @@ static int conf_choice(struct menu *menu
 		printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
 		def_sym = sym_get_choice_value(sym);
 		cnt = def = 0;
-		line[0] = '0';
-		line[1] = 0;
+		line[0] = '\0';
+		line[1] = '\0';
 		for (child = menu->list; child; child = child->next) {
 			if (!menu_is_visible(child))
 				continue;




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

* Re: [patch] pedantic correctness cleanup for conf.c in scripts/kconfig/ .
  2005-01-03 23:35 [patch] pedantic correctness cleanup for conf.c in scripts/kconfig/ Jesper Juhl
@ 2005-01-05 12:26 ` Roman Zippel
  2005-01-05 21:58   ` Jesper Juhl
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Zippel @ 2005-01-05 12:26 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel

Hi,

On Tuesday 04 January 2005 00:35, Jesper Juhl wrote:

> @@ -305,8 +305,8 @@ static int conf_choice(struct menu *menu
>    printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
>    def_sym = sym_get_choice_value(sym);
>    cnt = def = 0;
> -  line[0] = '0';
> -  line[1] = 0;
> +  line[0] = '\0';
> +  line[1] = '\0';
>    for (child = menu->list; child; child = child->next) {
>     if (!menu_is_visible(child))
>      continue;

This would make a difference and even the other change is not an improvement, 
0 is special string marker and not a character.

bye, Roman


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

* Re: [patch] pedantic correctness cleanup for conf.c in scripts/kconfig/ .
  2005-01-05 12:26 ` Roman Zippel
@ 2005-01-05 21:58   ` Jesper Juhl
  0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2005-01-05 21:58 UTC (permalink / raw)
  To: Roman Zippel; +Cc: linux-kernel

On Wed, 5 Jan 2005, Roman Zippel wrote:

> Hi,
> 
> On Tuesday 04 January 2005 00:35, Jesper Juhl wrote:
> 
> > @@ -305,8 +305,8 @@ static int conf_choice(struct menu *menu
> >    printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
> >    def_sym = sym_get_choice_value(sym);
> >    cnt = def = 0;
> > -  line[0] = '0';
> > -  line[1] = 0;
> > +  line[0] = '\0';
> > +  line[1] = '\0';
> >    for (child = menu->list; child; child = child->next) {
> >     if (!menu_is_visible(child))
> >      continue;
> 
> This would make a difference and even the other change is not an improvement, 
> 0 is special string marker and not a character.
> 
You are right. that bit actually makes a difference, that was not my 
intention but a silly error. I didn't spot it at the time for some reason 
and the testing I did didn't show any behavioral differences so it slipped 
through.
As to 0 vs \0 I know \0 ("the null character") has the value 0 (zero) so 
the compiled code will be identical, but using \0 is IMO a good idea to 
emphazise the character nature of it. But, I don't care greatly, I just 
saw it and thought "ohh, why 0 and not the null char? Let's fix that up", 
so I wrote a patch to make that change in case others agreed with me.


-- 
Jesper



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

end of thread, other threads:[~2005-01-05 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-03 23:35 [patch] pedantic correctness cleanup for conf.c in scripts/kconfig/ Jesper Juhl
2005-01-05 12:26 ` Roman Zippel
2005-01-05 21:58   ` Jesper Juhl

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).