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

Re: [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables

From
Sebastian Schuberth <sschuberth@gmail.com>
Date
Oct 18, 2011, 18:12 UTC
Message-ID
<4E9DC198.9040108@gmail.com>
In-Reply-To
<7vehyagq82.fsf@alter.siamese.dyndns.org>
GCC 4.6 claims that
    error: 'best.len' may be used uninitialized in this function

so silence that warning which is treated as an error by also initializing the "len" members of the struct.

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
---
 compat/inet_ntop.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index ea249c6..9e9f6fb 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -98,7 +98,8 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
 	for (i = 0; i < NS_IN6ADDRSZ; i++)
 		words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
 	best.base = -1;
-	cur.base = -1;
+	best.len = 0;
+	cur = best;
 	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
 		if (words[i] == 0) {
 			if (cur.base == -1)
-- 
1.7.7.msysgit.1
Previous: Junio C Hamano
Message 3 of 3 in “inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables”
  1. inet_ntop.c: Work around GCC 4.6's detection of uninitialized variablesSebastian Schuberth, Oct 18, 2011
  2. Junio C HamanoOct 18, 2011
  3. Sebastian SchuberthOct 18, 2011

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.