changeset 16266:b1498fa45ab4

inet_ntop: silence gcc warning 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 <eblake@redhat.com>
author Eric Blake <eblake@redhat.com>
date Wed, 11 Jan 2012 14:48:31 -0700
parents 8c89b3a442f2
children 93b1cf6aadc8
files ChangeLog lib/inet_ntop.c
diffstat 2 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-11  Eric Blake  <eblake@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  <ldv@altlinux.org>
 
 	getloadavg test: skip the test on GNU/Linux without /proc mounted
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -166,6 +166,7 @@
   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++)
     {