Skip to contentSkip to conversation

DTC: Quiet a bogus "May be used uninitialized" warning.

PATCH In review Jon Loeliger 2 participants 2 messages Oct 19, 2007 – Oct 20, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 2/4 DTC: Quiet a bogus "May be used uninitialized" warning.

---
 flattree.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
flattree.c +1 -1
index a26e71b..5889900 100644
@@ -136,7 +136,7 @@ static void asm_emit_cell(void *e, cell_t val)
 static void asm_emit_string(void *e, char *str, int len)
 {
 	FILE *f = e;
-	char c;
+	char c = 0;
 
 	if (len != 0) {
 		/* XXX: ewww */
Signature · 1 line
1.5.3.1.139.g9346b
#1 lore raw
Quoted 2 lines · Jon Loeliger

I don't like this one much. The warning is indeed bogus, and my compiler version, at least, doesn't generate it

	mulberryst:~/dtc$ gcc --version
	gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)

Putting in the initializer would mean that even on non-broken compilers, we wouldn't get the warning if we ever changed the contained code so that it really should generate an unitialized variable warning.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson