git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
@ 2016-04-10 22:59 Ramsay Jones
  2016-04-11  4:20 ` Torsten Bögershausen
  0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2016-04-10 22:59 UTC (permalink / raw)
  To: David Turner, Nguyen Thai Ngoc Duy
  Cc: Jeff King, Junio C Hamano, GIT Mailing-list


Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 git-compat-util.h | 17 -----------------
 index-helper.c    |  4 ++--
 read-cache.c      |  2 +-
 3 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 0e35c13..c90c8c6 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
 #define getc_unlocked(fh) getc(fh)
 #endif
 
-#ifdef __linux__
-#define UNIX_PATH_MAX 108
-#elif defined(__APPLE__) || defined(BSD)
-#define UNIX_PATH_MAX 104
-#else
-/*
- * Quoth POSIX: The size of sun_path has intentionally been left
- * undefined. This is because different implementations use different
- * sizes. For example, 4.3 BSD uses a size of 108, and 4.4 BSD uses a
- * size of 104. Since most implementations originate from BSD
- * versions, the size is typically in the range 92 to 108.
- *
- * Thanks, POSIX!  Super-helpful!  Hope we don't overflow any buffers!
- */
-#define UNIX_PATH_MAX 92
-#endif
-
 #endif
diff --git a/index-helper.c b/index-helper.c
index 4d08ff4..4a8e2ae 100644
--- a/index-helper.c
+++ b/index-helper.c
@@ -309,7 +309,7 @@ static int setup_socket(const char *socket_path)
 	int len;
 
 	len = strlen(socket_path);
-	if (len > UNIX_PATH_MAX - 1)
+	if (len > sizeof(address.sun_path) - 1)
 		die("path %s is too long for a socket", socket_path);
 
 	fd = socket(PF_UNIX, SOCK_STREAM, 0);
@@ -317,7 +317,7 @@ static int setup_socket(const char *socket_path)
 		return -1;
 
 	address.sun_family = AF_UNIX;
-	strncpy(address.sun_path, socket_path, UNIX_PATH_MAX);
+	strncpy(address.sun_path, socket_path, sizeof(address.sun_path));
 
 	if (bind(fd, (struct sockaddr *) &address, sizeof(address)))
 		die_errno(_("failed to bind to socket %s"), socket_path);
diff --git a/read-cache.c b/read-cache.c
index ab2fbaa..c7053d8 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1728,7 +1728,7 @@ int connect_to_index_helper(void)
 	int fd;
 
 	if (readlink(git_path("index-helper.path"), address.sun_path,
-		     UNIX_PATH_MAX) < 0)
+		     sizeof(address.sun_path)) < 0)
 		return -1;
 
 	fd = socket(PF_UNIX, SOCK_STREAM, 0);
-- 
2.8.0

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

* Re: [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
  2016-04-10 22:59 [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin Ramsay Jones
@ 2016-04-11  4:20 ` Torsten Bögershausen
  2016-04-11 13:30   ` Ramsay Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Torsten Bögershausen @ 2016-04-11  4:20 UTC (permalink / raw)
  To: Ramsay Jones, David Turner, Nguyen Thai Ngoc Duy
  Cc: Jeff King, Junio C Hamano, GIT Mailing-list

On 04/11/2016 12:59 AM, Ramsay Jones wrote:
The header mentions cygwin, but changes it for linux, BSD and Mac OS as 
well.
Is this intentional ?
> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> ---
>   git-compat-util.h | 17 -----------------
>   index-helper.c    |  4 ++--
>   read-cache.c      |  2 +-
>   3 files changed, 3 insertions(+), 20 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index 0e35c13..c90c8c6 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
>   #define getc_unlocked(fh) getc(fh)
>   #endif
>   
> -#ifdef __linux__
> -#define UNIX_PATH_MAX 108
> -#elif defined(__APPLE__) || defined(BSD)
> -#define UNIX_PATH_MAX 104
> -#else
Can we use a #elif __CYGWIN__ here to fix the re-definition just for cygwi ?

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

* Re: [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
  2016-04-11  4:20 ` Torsten Bögershausen
@ 2016-04-11 13:30   ` Ramsay Jones
  2016-04-11 21:55     ` David Turner
  0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2016-04-11 13:30 UTC (permalink / raw)
  To: Torsten Bögershausen, David Turner, Nguyen Thai Ngoc Duy
  Cc: Jeff King, Junio C Hamano, GIT Mailing-list



On 11/04/16 05:20, Torsten Bögershausen wrote:
> On 04/11/2016 12:59 AM, Ramsay Jones wrote:
> The header mentions cygwin, but changes it for linux, BSD and Mac OS as well.
> Is this intentional ?

Yes. I only compile on 32/64-bit linux and 64-bit cygwin these days, so I only
noticed the warnings (yes I wrote error, but it should be warning) on cygwin.
Other systems may suffer the same warnings, of course.

>> Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
>> ---
>>   git-compat-util.h | 17 -----------------
>>   index-helper.c    |  4 ++--
>>   read-cache.c      |  2 +-
>>   3 files changed, 3 insertions(+), 20 deletions(-)
>>
>> diff --git a/git-compat-util.h b/git-compat-util.h
>> index 0e35c13..c90c8c6 100644
>> --- a/git-compat-util.h
>> +++ b/git-compat-util.h
>> @@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
>>   #define getc_unlocked(fh) getc(fh)
>>   #endif
>>   -#ifdef __linux__
>> -#define UNIX_PATH_MAX 108
>> -#elif defined(__APPLE__) || defined(BSD)
>> -#define UNIX_PATH_MAX 104
>> -#else
> Can we use a #elif __CYGWIN__ here to fix the re-definition just for cygwi ?

As I said in the cover letter, that is an option - but why bother with
UNIX_PATH_MAX at all?

ATB,
Ramsay Jones

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

* Re: [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
  2016-04-11 13:30   ` Ramsay Jones
@ 2016-04-11 21:55     ` David Turner
  0 siblings, 0 replies; 4+ messages in thread
From: David Turner @ 2016-04-11 21:55 UTC (permalink / raw)
  To: Ramsay Jones, Torsten Bögershausen, Nguyen Thai Ngoc Duy
  Cc: Jeff King, Junio C Hamano, GIT Mailing-list

On Mon, 2016-04-11 at 14:30 +0100, Ramsay Jones wrote:
> 
> On 11/04/16 05:20, Torsten Bögershausen wrote:
> > On 04/11/2016 12:59 AM, Ramsay Jones wrote:
> > The header mentions cygwin, but changes it for linux, BSD and Mac
> > OS as well.
> > Is this intentional ?
> 
> Yes. I only compile on 32/64-bit linux and 64-bit cygwin these days,
> so I only
> noticed the warnings (yes I wrote error, but it should be warning) on
> cygwin.
> Other systems may suffer the same warnings, of course.
> 
> > > Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
> > > ---
> > >   git-compat-util.h | 17 -----------------
> > >   index-helper.c    |  4 ++--
> > >   read-cache.c      |  2 +-
> > >   3 files changed, 3 insertions(+), 20 deletions(-)
> > > 
> > > diff --git a/git-compat-util.h b/git-compat-util.h
> > > index 0e35c13..c90c8c6 100644
> > > --- a/git-compat-util.h
> > > +++ b/git-compat-util.h
> > > @@ -1043,21 +1043,4 @@ struct tm *git_gmtime_r(const time_t *,
> > > struct tm *);
> > >   #define getc_unlocked(fh) getc(fh)
> > >   #endif
> > >   -#ifdef __linux__
> > > -#define UNIX_PATH_MAX 108
> > > -#elif defined(__APPLE__) || defined(BSD)
> > > -#define UNIX_PATH_MAX 104
> > > -#else
> > Can we use a #elif __CYGWIN__ here to fix the re-definition just
> > for cygwi ?
> 
> As I said in the cover letter, that is an option - but why bother
> with
> UNIX_PATH_MAX at all?

Will remove UNIX_PATH_MAX in favor of sizeof().

Thanks.

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

end of thread, other threads:[~2016-04-11 21:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-10 22:59 [PATCH 1/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin Ramsay Jones
2016-04-11  4:20 ` Torsten Bögershausen
2016-04-11 13:30   ` Ramsay Jones
2016-04-11 21:55     ` David Turner

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).