# [PATCH 2/2] Fix variable initialization in insert_packed_refs().

3 messages from 2010-01-14 to 2010-01-15. Participants: Richard Weinberger, Johannes Sixt.
Thread: https://gitlist.dev/t/22227

## Richard Weinberger, 2010-01-14 23:29

Subject: [PATCH 2/2] Fix variable initialization in insert_packed_refs().
Message-ID: <201001150029.01486.richard@nod.at>
URL: https://gitlist.dev/e/201001150029.01486.richard%40nod.at

```
Signed-off-by: Richard Weinberger <richard@nod.at>
---
 transport.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/transport.c b/transport.c
index 3b489b3..ecc20a1 100644
--- a/transport.c
+++ b/transport.c
@@ -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);
-- 
1.6.5.7

```

## Johannes Sixt, 2010-01-15 07:34

Subject: Re: [PATCH 2/2] Fix variable initialization in insert_packed_refs().
Message-ID: <4B501A9D.6060703@viscovery.net>
URL: https://gitlist.dev/e/4B501A9D.6060703%40viscovery.net
In-Reply-To: <201001150029.01486.richard@nod.at>

```
Richard Weinberger schrieb:
> -		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

```

## Richard Weinberger, 2010-01-15 11:02

Subject: Re: [PATCH 2/2] Fix variable initialization in insert_packed_refs().
Message-ID: <201001151202.38762.richard@nod.at>
URL: https://gitlist.dev/e/201001151202.38762.richard%40nod.at
In-Reply-To: <4B501A9D.6060703@viscovery.net>

```
Am Freitag 15 Januar 2010 08:34:53 schrieb Johannes Sixt:
> 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

```
