Re: [PATCH] Fixed a gcc 4.0.1 complaint about an uninitialized variable
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 2, 2007, 05:37 UTC
- Message-ID
- <7v8x5h6wd0.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <1193971102-61907-2-git-send-email-blaker@gmail.com>
Blake Ramsdell <blaker@gmail.com> writes:
Show 10 quoted lines
> diff --git a/transport.c b/transport.c
> index 400af71..cac1870 100644
> --- a/transport.c
> +++ b/transport.c
> @@ -107,7 +107,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
> return;
>
> for (;;) {
> - int cmp, len;
> + int cmp = 0, len;Yeah, if you follow the logic, it is clear that the variable is never used while unset, but gcc is not careful enough to see it.
It is customary to use
int cmp = cmp;
for something like this. There are already other instances of such phony initializations in the code elsewhere.