git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables
@ 2011-10-18 16:25 Sebastian Schuberth
  2011-10-18 17:32 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Schuberth @ 2011-10-18 16:25 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, mschub

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 |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index ea249c6..60b5a1d 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -98,7 +98,9 @@ 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;
+	best.len = 0;
 	cur.base = -1;
+	cur.len = 0;
 	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
 		if (words[i] == 0) {
 			if (cur.base == -1)
-- 
1.7.7.msysgit.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables
  2011-10-18 16:25 [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables Sebastian Schuberth
@ 2011-10-18 17:32 ` Junio C Hamano
  2011-10-18 18:12   ` Sebastian Schuberth
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2011-10-18 17:32 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: git, mschub

Sebastian Schuberth <sschuberth@gmail.com> writes:

> 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 |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
> index ea249c6..60b5a1d 100644
> --- a/compat/inet_ntop.c
> +++ b/compat/inet_ntop.c
> @@ -98,7 +98,9 @@ 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;
> +	best.len = 0;
>  	cur.base = -1;
> +	cur.len = 0;

It may be just the "taste" thing, but I wonder if

	best.base = -1;
        best.len = 0;
        cur = best;

might be easier on the eyes.

Will queue as-is anyway. Thanks.

>  	for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
>  		if (words[i] == 0) {
>  			if (cur.base == -1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables
  2011-10-18 17:32 ` Junio C Hamano
@ 2011-10-18 18:12   ` Sebastian Schuberth
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Schuberth @ 2011-10-18 18:12 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, mschub

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-18 18:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-18 16:25 [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables Sebastian Schuberth
2011-10-18 17:32 ` Junio C Hamano
2011-10-18 18:12   ` Sebastian Schuberth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).