# HG changeset patch # User Eric Blake # Date 1326383048 25200 # Node ID 053f5a861da88a525fe9b5e095370aa3de5528d6 # Parent 2c5c6ce1dba41e4d2fb1d21b063288ed7a9ea49d inet_ntop: guard extra work by IF_LINT No need to penalize the code just to silence a gcc warning, so follow the conventions used elsewhere in gnulib. Clients that want to use extra warnings should also be using -Dlint. * lib/inet_ntop.c (inet_ntop6): Mark spurious initialization, for better code generation when not checking for warnings. Suggested by Paul Eggert and Jim Meyering. Signed-off-by: Eric Blake diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-01-12 Eric Blake + inet_ntop: guard extra work by IF_LINT + * lib/inet_ntop.c (inet_ntop6): Mark spurious initialization, for + better code generation when not checking for warnings. + Suggested by Paul Eggert and Jim Meyering. + strptime: fix regression on mingw * lib/strptime.c (__strptime_internal) [!_LIBC && !HAVE_TM_GMTOFF]: Fix regression. Reported by Bruno Haible. diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -38,6 +38,16 @@ /* Specification. */ #include +/* Use this to suppress gcc's "...may be used before initialized" warnings. + Beware: The Code argument must not contain commas. */ +#ifndef IF_LINT +# ifdef lint +# define IF_LINT(Code) Code +# else +# define IF_LINT(Code) /* empty */ +# endif +#endif + #if HAVE_DECL_INET_NTOP # undef inet_ntop @@ -166,8 +176,9 @@ 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; + IF_LINT(best.len = 0); + IF_LINT(cur.len = 0); for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { if (words[i] == 0)