{"thread":{"id":"41984","subject":"[PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin","startedAt":"2016-04-10T22:59:58Z","lastAt":"2016-04-11T21:55:49Z","messageCount":4,"participants":["Ramsay Jones","Torsten Bögershausen","David Turner"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"283114","messageId":"570ADAEE.20201@ramsayjones.plus.com","threadId":"41984","inReplyTo":null,"subject":"[PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2016-04-10T22:59:58Z","receivedAt":"2016-04-10T22:59:58Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\nSigned-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n---\n git-compat-util.h | 17 -----------------\n index-helper.c    |  4 ++--\n read-cache.c      |  2 +-\n 3 files changed, 3 insertions(+), 20 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex 0e35c13..c90c8c6 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);\n #define getc_unlocked(fh) getc(fh)\n #endif\n \n-#ifdef __linux__\n-#define UNIX_PATH_MAX 108\n-#elif defined(__APPLE__) || defined(BSD)\n-#define UNIX_PATH_MAX 104\n-#else\n-/*\n- * Quoth POSIX: The size of sun_path has intentionally been left\n- * undefined. This is because different implementations use different\n- * sizes. For example, 4.3 BSD uses a size of 108, and 4.4 BSD uses a\n- * size of 104. Since most implementations originate from BSD\n- * versions, the size is typically in the range 92 to 108.\n- *\n- * Thanks, POSIX!  Super-helpful!  Hope we don't overflow any buffers!\n- */\n-#define UNIX_PATH_MAX 92\n-#endif\n-\n #endif\ndiff --git a/index-helper.c b/index-helper.c\nindex 4d08ff4..4a8e2ae 100644\n--- a/index-helper.c\n+++ b/index-helper.c\n@@ -309,7 +309,7 @@ static int setup_socket(const char *socket_path)\n \tint len;\n \n \tlen = strlen(socket_path);\n-\tif (len > UNIX_PATH_MAX - 1)\n+\tif (len > sizeof(address.sun_path) - 1)\n \t\tdie(\"path %s is too long for a socket\", socket_path);\n \n \tfd = socket(PF_UNIX, SOCK_STREAM, 0);\n@@ -317,7 +317,7 @@ static int setup_socket(const char *socket_path)\n \t\treturn -1;\n \n \taddress.sun_family = AF_UNIX;\n-\tstrncpy(address.sun_path, socket_path, UNIX_PATH_MAX);\n+\tstrncpy(address.sun_path, socket_path, sizeof(address.sun_path));\n \n \tif (bind(fd, (struct sockaddr *) &address, sizeof(address)))\n \t\tdie_errno(_(\"failed to bind to socket %s\"), socket_path);\ndiff --git a/read-cache.c b/read-cache.c\nindex ab2fbaa..c7053d8 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1728,7 +1728,7 @@ int connect_to_index_helper(void)\n \tint fd;\n \n \tif (readlink(git_path(\"index-helper.path\"), address.sun_path,\n-\t\t     UNIX_PATH_MAX) < 0)\n+\t\t     sizeof(address.sun_path)) < 0)\n \t\treturn -1;\n \n \tfd = socket(PF_UNIX, SOCK_STREAM, 0);\n-- \n2.8.0\n"},{"id":"283127","messageId":"570B2605.4040305@web.de","threadId":"41984","inReplyTo":"570ADAEE.20201@ramsayjones.plus.com","subject":"Re: [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2016-04-11T04:20:21Z","receivedAt":"2016-04-11T04:20:21Z","isPatch":true,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On 04/11/2016 12:59 AM, Ramsay Jones wrote:\nThe header mentions cygwin, but changes it for linux, BSD and Mac OS as \nwell.\nIs this intentional ?\n> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> ---\n>   git-compat-util.h | 17 -----------------\n>   index-helper.c    |  4 ++--\n>   read-cache.c      |  2 +-\n>   3 files changed, 3 insertions(+), 20 deletions(-)\n>\n> diff --git a/git-compat-util.h b/git-compat-util.h\n> index 0e35c13..c90c8c6 100644\n> --- a/git-compat-util.h\n> +++ b/git-compat-util.h\n> @@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);\n>   #define getc_unlocked(fh) getc(fh)\n>   #endif\n>   \n> -#ifdef __linux__\n> -#define UNIX_PATH_MAX 108\n> -#elif defined(__APPLE__) || defined(BSD)\n> -#define UNIX_PATH_MAX 104\n> -#else\nCan we use a #elif __CYGWIN__ here to fix the re-definition just for cygwi ?\n"},{"id":"283136","messageId":"570BA6EF.7020202@ramsayjones.plus.com","threadId":"41984","inReplyTo":"570B2605.4040305@web.de","subject":"Re: [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin","fromName":"Ramsay Jones","fromEmail":"ramsay@ramsayjones.plus.com","sentAt":"2016-04-11T13:30:23Z","receivedAt":"2016-04-11T13:30:23Z","isPatch":true,"sender":{"key":"ramsay@ramsayjones.plus.com","avatar":"https://avatars.githubusercontent.com/u/33702710?v=4"},"body":"\n\nOn 11/04/16 05:20, Torsten Bögershausen wrote:\n> On 04/11/2016 12:59 AM, Ramsay Jones wrote:\n> The header mentions cygwin, but changes it for linux, BSD and Mac OS as well.\n> Is this intentional ?\n\nYes. I only compile on 32/64-bit linux and 64-bit cygwin these days, so I only\nnoticed the warnings (yes I wrote error, but it should be warning) on cygwin.\nOther systems may suffer the same warnings, of course.\n\n>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n>> ---\n>>   git-compat-util.h | 17 -----------------\n>>   index-helper.c    |  4 ++--\n>>   read-cache.c      |  2 +-\n>>   3 files changed, 3 insertions(+), 20 deletions(-)\n>>\n>> diff --git a/git-compat-util.h b/git-compat-util.h\n>> index 0e35c13..c90c8c6 100644\n>> --- a/git-compat-util.h\n>> +++ b/git-compat-util.h\n>> @@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);\n>>   #define getc_unlocked(fh) getc(fh)\n>>   #endif\n>>   -#ifdef __linux__\n>> -#define UNIX_PATH_MAX 108\n>> -#elif defined(__APPLE__) || defined(BSD)\n>> -#define UNIX_PATH_MAX 104\n>> -#else\n> Can we use a #elif __CYGWIN__ here to fix the re-definition just for cygwi ?\n\nAs I said in the cover letter, that is an option - but why bother with\nUNIX_PATH_MAX at all?\n\nATB,\nRamsay Jones\n"},{"id":"283159","messageId":"1460411749.5540.22.camel@twopensource.com","threadId":"41984","inReplyTo":"570BA6EF.7020202@ramsayjones.plus.com","subject":"Re: [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin","fromName":"David Turner","fromEmail":"dturner@twopensource.com","sentAt":"2016-04-11T21:55:49Z","receivedAt":"2016-04-11T21:55:49Z","isPatch":true,"sender":{"key":"novalis@novalis.org","avatar":"https://avatars.githubusercontent.com/u/77003?v=4"},"body":"On Mon, 2016-04-11 at 14:30 +0100, Ramsay Jones wrote:\n> \n> On 11/04/16 05:20, Torsten Bögershausen wrote:\n> > On 04/11/2016 12:59 AM, Ramsay Jones wrote:\n> > The header mentions cygwin, but changes it for linux, BSD and Mac\n> > OS as well.\n> > Is this intentional ?\n> \n> Yes. I only compile on 32/64-bit linux and 64-bit cygwin these days,\n> so I only\n> noticed the warnings (yes I wrote error, but it should be warning) on\n> cygwin.\n> Other systems may suffer the same warnings, of course.\n> \n> > > Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>\n> > > ---\n> > >   git-compat-util.h | 17 -----------------\n> > >   index-helper.c    |  4 ++--\n> > >   read-cache.c      |  2 +-\n> > >   3 files changed, 3 insertions(+), 20 deletions(-)\n> > > \n> > > diff --git a/git-compat-util.h b/git-compat-util.h\n> > > index 0e35c13..c90c8c6 100644\n> > > --- a/git-compat-util.h\n> > > +++ b/git-compat-util.h\n> > > @@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *,\n> > > struct tm *);\n> > >   #define getc_unlocked(fh) getc(fh)\n> > >   #endif\n> > >   -#ifdef __linux__\n> > > -#define UNIX_PATH_MAX 108\n> > > -#elif defined(__APPLE__) || defined(BSD)\n> > > -#define UNIX_PATH_MAX 104\n> > > -#else\n> > Can we use a #elif __CYGWIN__ here to fix the re-definition just\n> > for cygwi ?\n> \n> As I said in the cover letter, that is an option - but why bother\n> with\n> UNIX_PATH_MAX at all?\n\nWill remove UNIX_PATH_MAX in favor of sizeof().\n\nThanks.\n"}]}