{"thread":{"id":"28714","subject":"[PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables","startedAt":"2011-10-18T16:25:50Z","lastAt":"2011-10-18T18:12:40Z","messageCount":3,"participants":["Sebastian Schuberth","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"177951","messageId":"4E9DA88E.40500@gmail.com","threadId":"28714","inReplyTo":null,"subject":"[PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2011-10-18T16:25:50Z","receivedAt":"2011-10-18T16:25:50Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"GCC 4.6 claims that\n\n    error: 'best.len' may be used uninitialized in this function\n\nso silence that warning which is treated as an error by also initializing\nthe \"len\" members of the struct.\n\nSigned-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n---\n compat/inet_ntop.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/compat/inet_ntop.c b/compat/inet_ntop.c\nindex ea249c6..60b5a1d 100644\n--- a/compat/inet_ntop.c\n+++ b/compat/inet_ntop.c\n@@ -98,7 +98,9 @@ inet_ntop6(const u_char *src, char *dst, size_t size)\n \tfor (i = 0; i < NS_IN6ADDRSZ; i++)\n \t\twords[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));\n \tbest.base = -1;\n+\tbest.len = 0;\n \tcur.base = -1;\n+\tcur.len = 0;\n \tfor (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {\n \t\tif (words[i] == 0) {\n \t\t\tif (cur.base == -1)\n-- \n1.7.7.msysgit.1\n"},{"id":"177955","messageId":"7vehyagq82.fsf@alter.siamese.dyndns.org","threadId":"28714","inReplyTo":"4E9DA88E.40500@gmail.com","subject":"Re: [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-18T17:32:45Z","receivedAt":"2011-10-18T17:32:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sebastian Schuberth <sschuberth@gmail.com> writes:\n\n> GCC 4.6 claims that\n>\n>     error: 'best.len' may be used uninitialized in this function\n>\n> so silence that warning which is treated as an error by also initializing\n> the \"len\" members of the struct.\n>\n> Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n> ---\n>  compat/inet_ntop.c |    2 ++\n>  1 files changed, 2 insertions(+), 0 deletions(-)\n>\n> diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c\n> index ea249c6..60b5a1d 100644\n> --- a/compat/inet_ntop.c\n> +++ b/compat/inet_ntop.c\n> @@ -98,7 +98,9 @@ inet_ntop6(const u_char *src, char *dst, size_t size)\n>  \tfor (i = 0; i < NS_IN6ADDRSZ; i++)\n>  \t\twords[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));\n>  \tbest.base = -1;\n> +\tbest.len = 0;\n>  \tcur.base = -1;\n> +\tcur.len = 0;\n\nIt may be just the \"taste\" thing, but I wonder if\n\n\tbest.base = -1;\n        best.len = 0;\n        cur = best;\n\nmight be easier on the eyes.\n\nWill queue as-is anyway. Thanks.\n\n>  \tfor (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {\n>  \t\tif (words[i] == 0) {\n>  \t\t\tif (cur.base == -1)\n"},{"id":"177959","messageId":"4E9DC198.9040108@gmail.com","threadId":"28714","inReplyTo":"7vehyagq82.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] inet_ntop.c: Work around GCC 4.6's detection of uninitialized variables","fromName":"Sebastian Schuberth","fromEmail":"sschuberth@gmail.com","sentAt":"2011-10-18T18:12:40Z","receivedAt":"2011-10-18T18:12:40Z","isPatch":true,"sender":{"key":"sschuberth@gmail.com","avatar":"https://avatars.githubusercontent.com/u/349154?v=4"},"body":"GCC 4.6 claims that\n\n    error: 'best.len' may be used uninitialized in this function\n\nso silence that warning which is treated as an error by also initializing\nthe \"len\" members of the struct.\n\nSigned-off-by: Sebastian Schuberth <sschuberth@gmail.com>\n---\n compat/inet_ntop.c |    3 ++-\n 1 files changed, 2 insertions(+), 1 deletions(-)\n\ndiff --git a/compat/inet_ntop.c b/compat/inet_ntop.c\nindex ea249c6..9e9f6fb 100644\n--- a/compat/inet_ntop.c\n+++ b/compat/inet_ntop.c\n@@ -98,7 +98,8 @@ inet_ntop6(const u_char *src, char *dst, size_t size)\n \tfor (i = 0; i < NS_IN6ADDRSZ; i++)\n \t\twords[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));\n \tbest.base = -1;\n-\tcur.base = -1;\n+\tbest.len = 0;\n+\tcur = best;\n \tfor (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {\n \t\tif (words[i] == 0) {\n \t\t\tif (cur.base == -1)\n-- \n1.7.7.msysgit.1\n"}]}