Skip to contentSkip to conversation

Fix variable initialization in insert_packed_refs().

PATCH In review Richard Weinberger 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Fix variable initialization in insert_packed_refs().

---
 transport.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
transport.c +0 -0
index 3b489b3..ecc20a1 100644
@@ -102,7 +102,7 @@ static void insert_packed_refs(const char *packed_refs, 

struct ref **list)
return;

for (;;) {
- int cmp = cmp, len;
+ int cmp, len;

if (!fgets(buffer, sizeof(buffer), f)) {
fclose(f);

Signature · 1 line
1.6.5.7
#1 lore raw

Review

Quoted 2 lines · Richard Weinberger
(quoted diff) +1 -1
-		int cmp = cmp, len;
+		int cmp, len;

If you look around in the code, you'll find more *cough* initializations *cough* like this. They are written this way for a reason: they avoid unwarranted compiler warnings "'foo' may be used uninitialized". Are you saying that this warning is not triggered anymore after your change?

-- Hannes

#2 lore raw

Am Freitag 15 Januar 2010 08:34:53 schrieb Johannes Sixt:

Quoted 5 lines

If you look around in the code, you'll find more *cough* initializations *cough* like this. They are written this way for a reason: they avoid unwarranted compiler warnings "'foo' may be used uninitialized". Are you saying that this warning is not triggered anymore after your change?

I don't get a warning after my change.
But I'm using on this system a quite old gcc (4.3.1). I'll recompile git with a more recent gcc and see what happens.

Just for clarification:
"int cmp = cmp;"
*suppresses* only the warning but "cmp" is still uninitialized? (I did'nt know this trick before.)

//richard