gcc -O2 couldn't tell that if best.base != -1, then best.len
was necessarily initialized.

* lib/inet_ntop.c (inet_ntop6): Initialize best.base.
Reported by Daniel P. Berrange.

Signed-off-by: Eric Blake <ebl...@redhat.com>
---
 ChangeLog       |    6 ++++++
 lib/inet_ntop.c |    1 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9d5f746..3399dda 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-11  Eric Blake  <ebl...@redhat.com>
+
+       inet_ntop: silence gcc warning
+       * lib/inet_ntop.c (inet_ntop6): Initialize best.base.
+       Reported by Daniel P. Berrange.
+
 2012-01-11  Dmitry V. Levin  <l...@altlinux.org>

        getloadavg test: skip the test on GNU/Linux without /proc mounted
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index a487019..d7e6b23 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -166,6 +166,7 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t 
size)
   for (i = 0; i < NS_IN6ADDRSZ; i += 2)
     words[i / 2] = (src[i] << 8) | src[i + 1];
   best.base = -1;
+  best.len = 0;
   cur.base = -1;
   for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
     {
-- 
1.7.7.5


Reply via email to