{"thread":{"id":"40172","subject":"[PATCH] compat/inet_ntop.c: Use INET_ADDRSTRLEN and INET6_ADDRSTRLEN macroses","startedAt":"2015-08-25T10:34:39Z","lastAt":"2015-08-25T12:13:32Z","messageCount":2,"participants":["brilliantov@inbox.ru","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"268638","messageId":"1440498879-12382-1-git-send-email-brilliantov@inbox.ru","threadId":"40172","inReplyTo":null,"subject":"[PATCH] compat/inet_ntop.c: Use INET_ADDRSTRLEN and INET6_ADDRSTRLEN macroses","fromName":"","fromEmail":"brilliantov@inbox.ru","sentAt":"2015-08-25T10:34:39Z","receivedAt":"2015-08-25T10:34:39Z","isPatch":true,"sender":{"key":"brilliantov@inbox.ru","avatar":null},"body":"From: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>\n\nSigned-off-by: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>\n---\n compat/inet_ntop.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/inet_ntop.c b/compat/inet_ntop.c\nindex 90b7cc4..fcd3b15 100644\n--- a/compat/inet_ntop.c\n+++ b/compat/inet_ntop.c\n@@ -47,7 +47,7 @@ static const char *\n inet_ntop4(const u_char *src, char *dst, size_t size)\n {\n \tstatic const char fmt[] = \"%u.%u.%u.%u\";\n-\tchar tmp[sizeof \"255.255.255.255\"];\n+\tchar tmp[INET_ADDRSTRLEN];\n \tint nprinted;\n \n \tnprinted = snprintf(tmp, sizeof(tmp), fmt, src[0], src[1], src[2], src[3]);\n@@ -78,7 +78,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)\n \t * Keep this in mind if you think this function should have been coded\n \t * to use pointer overlays.  All the world's not a VAX.\n \t */\n-\tchar tmp[sizeof \"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255\"], *tp;\n+\tchar tmp[INET6_ADDRSTRLEN], *tp;\n \tstruct { int base, len; } best, cur;\n \tunsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];\n \tint i;\n-- \n2.1.4\n"},{"id":"268640","messageId":"9f870e741fc573934ebfe40cd73aba81@www.dscho.org","threadId":"40172","inReplyTo":"1440498879-12382-1-git-send-email-brilliantov@inbox.ru","subject":"Re: [PATCH] compat/inet_ntop.c: Use INET_ADDRSTRLEN and INET6_ADDRSTRLEN macroses","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2015-08-25T12:13:32Z","receivedAt":"2015-08-25T12:13:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Kirill,\n\nOn 2015-08-25 12:34, brilliantov@inbox.ru wrote:\n> From: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>\n> \n> Signed-off-by: Brilliantov Kirill Vladimirovich <brilliantov@inbox.ru>\n\nThe commit message makes for an excellent place to fill in the reader on information that is not obvious from reading the patch. For example...\n\n> diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c\n> index 90b7cc4..fcd3b15 100644\n> --- a/compat/inet_ntop.c\n> +++ b/compat/inet_ntop.c\n> @@ -47,7 +47,7 @@ static const char *\n>  inet_ntop4(const u_char *src, char *dst, size_t size)\n>  {\n>  \tstatic const char fmt[] = \"%u.%u.%u.%u\";\n> -\tchar tmp[sizeof \"255.255.255.255\"];\n> +\tchar tmp[INET_ADDRSTRLEN];\n\nGiven that we are in compat/ space, i.e. in a space meant for platforms lacking POSIX functions and definitions, is it really safe to assume that INET_ADDRSTRLEN is available there?\n\n> @@ -78,7 +78,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)\n>  \t * Keep this in mind if you think this function should have been coded\n>  \t * to use pointer overlays.  All the world's not a VAX.\n>  \t */\n> -\tchar tmp[sizeof \"ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255\"], *tp;\n> +\tchar tmp[INET6_ADDRSTRLEN], *tp;\n\nAre we really, absolutely sure that INET6_ADDRSTRLEN is defined?\n\nAlso I wonder: what problem does this patch solve? Is the current way to determine the size of the `tmp` array incorrect?\n\nPlease use the commit message space to answer at least these questions.\n\nCiao,\nJohannes\n"}]}