Skip to contentSkip to conversation

checkout: squelch "'mode' may be used uninitialized in this function" warning

PATCH In review [email protected] 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkout: squelch "'mode' may be used uninitialized in this function" warning

From: David Soria Parra <[email protected]>

Use a 'fake' initialization for the 'mode' variable to work around a GCC warning as in 5a7a367. The necessary condition to initialize 'mode' will always be true but cannot be checked by the compiler.

---
 builtin/checkout.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/checkout.c +1 -1
index 84d3eb3..6b8bf31 100644
@@ -157,7 +157,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	unsigned char sha1[20];
 	mmbuffer_t result_buf;
 	unsigned char threeway[3][20];
-	unsigned mode;
+	unsigned mode = mode;
 
 	memset(threeway, 0, sizeof(threeway));
 	while (pos < active_nr) {
Signature · 1 line
1.7.8.GIT
#1 lore raw

Any update on this patch? Is it going to maint?

Quoted 24 lines · On 2012-04-30, [email protected] <[email protected]> wrote:

From: David Soria Parra <[email protected]>

Use a 'fake' initialization for the 'mode' variable to work around a GCC warning as in 5a7a367. The necessary condition to initialize 'mode' will always be true but cannot be checked by the compiler.

---
 builtin/checkout.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin/checkout.c +1 -1
index 84d3eb3..6b8bf31 100644
@@ -157,7 +157,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	unsigned char sha1[20];
 	mmbuffer_t result_buf;
 	unsigned char threeway[3][20];
-	unsigned mode;
+	unsigned mode = mode;
 
 	memset(threeway, 0, sizeof(threeway));
 	while (pos < active_nr) {
#2 lore raw
Quoted 1 line · David Soria Parra

Any update on this patch? Is it going to maint?

I doubt it:

Quoted 10 lines

builtin/checkout.c static int checkout_merged(int pos, struct checkout *state) · line 160

Quoted 10 lines
builtin/checkout.c +1 -1
index 84d3eb3..6b8bf31 100644
@@ -157,7 +157,7 @@ static int checkout_merged(int pos, struct checkout *state)
 	unsigned char sha1[20];
 	mmbuffer_t result_buf;
 	unsigned char threeway[3][20];
-	unsigned mode;
+	unsigned mode = mode;

What is this based on? This has been fixed since 335c6e4 (checkout_merged(): squelch false warning from some gcc, 2011-12-15), which was in v1.7.8.2.

-Peff