Skip to contentSkip to conversation

fix two compile time warnings

PATCH In review Maciej Żenczykowski 2 participants 5 messages Oct 20, 2010 – Nov 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix two compile time warnings

From: Maciej Żenczykowski <[email protected]>

jobs.c: In function 'sprint_status':
jobs.c:427: warning: format not a string literal and no format arguments

trap.c: In function 'exitshell':
trap.c:354: warning: variable 'status' might be clobbered by 'longjmp' or 'vfork'

---
 src/jobs.c |    2 +-
 src/trap.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
src/jobs.c +1 -1
index 826a9af..44a6401 100644
@@ -425,7 +425,7 @@ sprint_status(char *s, int status, int sigonly)
 				goto out;
 #endif
 		}
-		col = fmtstr(s, 32, strsignal(st));
+		col = fmtstr(s, 32, "%s", strsignal(st));
 		if (WCOREDUMP(status)) {
 			col += fmtstr(s + col, 16, " (core dumped)");
 		}
src/trap.c +1 -1
index 7bd60ab..a3c4397 100644
@@ -369,7 +369,7 @@ exitshell(void)
 {
 	struct jmploc loc;
 	char *p;
-	int status;
+	volatile int status;
 
 #ifdef HETIO
 	hetio_reset_term();
Signature · 1 line
1.7.1
#1 lore raw
Quoted 9 lines · Maciej Żenczykowski

From: Maciej Żenczykowski <[email protected]>

jobs.c: In function 'sprint_status':
jobs.c:427: warning: format not a string literal and no format arguments

trap.c: In function 'exitshell':
trap.c:354: warning: variable 'status' might be clobbered by 'longjmp' or 'vfork'

Thanks for the patch. I've applied the second hunk.

As for the first, if I get annoyed enough after upgrading my gcc then I'll think about it :) It's a false positive as strsignal should never return anything that requires "%s".

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
Quoted 5 lines

Thanks for the patch.  I've applied the second hunk.

As for the first, if I get annoyed enough after upgrading my gcc then I'll think about it :) It's a false positive as strsignal should never return anything that requires "%s".

That's unfortunate since it prevents a -Werror build of klibc (which includes dash) from succeeding.
Cheers,
Maciej

#3 lore raw
Quoted 8 lines · Maciej Żenczykowski
Quoted 5 lines

Thanks for the patch.  I've applied the second hunk.

As for the first, if I get annoyed enough after upgrading my gcc then I'll think about it :) It's a false positive as strsignal should never return anything that requires "%s".

That's unfortunate since it prevents a -Werror build of klibc (which includes dash) from succeeding.

And that's precisely why I would never use -Werror with gcc.

You can always apply this patch in klibc locally.

Cheers,

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#4 lore raw
Quoted 4 lines
Quoted 2 lines

That's unfortunate since it prevents a -Werror build of klibc (which includes dash) from succeeding.

And that's precisely why I would never use -Werror with gcc.

My personal experience has been that the warnings gcc produces are far more often a sign of real bugs
than they are spurious. Usually fixing them isn't particularly bothersome.

(although this is based on experience predominantly gained not on klibc or dash)

Quoted 1 line

You can always apply this patch in klibc locally.

I do, however, I prefer submitting patches upstream whenever possible.

I'll continue to maintain this one locally.

- Maciej