Re: [PATCH 4/4] transport: drop "int cmp = cmp" hack
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 25, 2013, 21:55 UTC
- Message-ID
- <7vk3ovw3ej.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <20130325210625.GA16386@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> I wonder, though, what made you look at this. It did not come up in my > list of -Wuninitialized warnings. Did it get triggered by one of the > other gcc versions?
No, but the function in question has that questionable construct written by somebody who does not understand linked list, and it dusgusted me enough to look at where that list came from, which inevitably made me notice that "return dummy.next" that made me go "wat?"
Show 19 quoted lines
>
>> diff --git a/transport.c b/transport.c
>> index 87b8f14..e6f9346 100644
>> --- a/transport.c
>> +++ b/transport.c
>> @@ -106,7 +106,8 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
>> return;
>>
>> for (;;) {
>> - int cmp, len;
>> + int cmp = 0; /* assigned before used */
>> + int len;
>>
>> if (!fgets(buffer, sizeof(buffer), f)) {
>> fclose(f);
>
> I think that's fine.
>
> -Peff