git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Avoid gcc compiler warning

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 8, 2014, 16:38 UTC
Message-ID
<b9e1cb1f858e71b964be4f752fcebc22cd944ebc.1418056722.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1418056722.git.johannes.schindelin@gmx.de>

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).

Since hash() is called from perf_hashmap() which accepts an unchecked integer value from the command line, the warning appears to be legitimate, even if the test-hashmap command is only called from the test suite.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 test-hashmap.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/test-hashmap.c b/test-hashmap.c
index 07aa7ec..40a126d 100644
--- a/test-hashmap.c
+++ b/test-hashmap.c
@@ -62,6 +62,8 @@ static unsigned int hash(unsigned int method, unsigned int i, const char *key)
 	case HASH_METHOD_0:
 		hash = 0;
 		break;
+	default:
+		die("Unknown method: %d", method);
 	}
 
 	if (method & HASH_METHOD_X2)
-- 
2.0.0.rc3.9669.g840d1f9
Next: Jeff King
Message 1 of 3 in “Avoid gcc compiler warning”
  1. Avoid gcc compiler warningJohannes Schindelin, Dec 8, 2014
  2. Jeff KingDec 9, 2014
  3. Johannes SchindelinDec 9, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.