Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test-hashmap: squelch gcc compiler warning
At least on this developer's MacOSX (Snow Leopard, gcc-4.2.1), GCC
prints a warning that 'hash' may be used uninitialized when
compiling test-hashmap that 'hash' may be used uninitialized (but
GCC 4.6.3 on this developer's Ubuntu server does not report this
problem).

The old compiler is wrong, of course, as the switch (method & 3)
statement already handles all the possible cases, but that does not
help in a scenario where it is hard or impossible to upgrade to a
newer compiler (e.g. being stuck on an older MacOSX and having to
rely on Xcode).

So let's just initialize the variable and be done with it, it is
hardly a crucial part of the code because it is only used by the
test suite and invisible to the end users.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Dec 9, 2014
1 parent 6a364ce commit 3b9a2b0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test-hashmap.c
Expand Up @@ -48,7 +48,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:
Expand Down

0 comments on commit 3b9a2b0

Please sign in to comment.