Re: [PATCH] Initialise hash variable to prevent compiler warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 13, 2014 at 10:53 PM, Felipe Franciosi <felipe@xxxxxxxxxxxx> wrote:
>
> On Mon, Oct 13, 2014 at 9:12 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
>>
>> Felipe Franciosi <felipe@xxxxxxxxxxxx> writes:
>>
>> > The 'hash' variable in test-hashmap.c is not initialised properly
>> > which causes some 'gcc' versions to complain during compilation.
>>
>> FNV/I/IDIV10/0 covers all the possibilities of (method & 3), I would
>> have to say that the compiler needs to be fixed.
>>
>> Or insert "default:" just before "case HASH_METHOD_0:" line?
>>
>> I dunno.

Hmm... The "default:" would work, but is it really that bad to
initialise a local variable in this case?

In any case, the compilation warning is annoying. Do you prefer the
default or the initialisation?

Cheers,
F.

>
>
> Hmm... The "default:" would work, but is it really that bad to initialise a
> local variable in this case?
>
> In any case, the compilation warning is annoying. Do you prefer the default
> or the initialisation?
>
> Cheers,
> F.
>
>>
>> >
>> > Signed-off-by: Felipe Franciosi <felipe@xxxxxxxxxxxx>
>> > ---
>> >  test-hashmap.c |    2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/test-hashmap.c b/test-hashmap.c
>> > index 07aa7ec..cc2891d 100644
>> > --- a/test-hashmap.c
>> > +++ b/test-hashmap.c
>> > @@ -47,7 +47,7 @@ static struct test_entry *alloc_test_entry(int hash,
>> > char *key, int klen,
>> >
>> >  static unsigned int hash(unsigned int method, unsigned int i, const
>> > char *key)
>> >  {
>> > -     unsigned int hash;
>> > +     unsigned int hash = 0;
>> >       switch (method & 3)
>> >       {
>> >       case HASH_METHOD_FNV:
>
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]