* [PATCH 0/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
@ 2016-04-10 22:57 Ramsay Jones
2016-04-11 13:33 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2016-04-10 22:57 UTC (permalink / raw)
To: David Turner, Nguyen Thai Ngoc Duy
Cc: Jeff King, Junio C Hamano, GIT Mailing-list
Hi David, Duy,
If you need to re-roll your 'dt/index-helper' branch, could you please
consider squashing these patches into the relevant patch (equivalent to
commit 12909da4 ("index-helper: new daemon for caching index and related
stuff", 06-04-2016)).
The above commit causes the cygwin build to throw a warning (many times)
about the redefinition of the UNIX_PATH_MAX macro, viz:
CC credential-store.o
In file included from cache.h:4:0,
from credential-store.c:1:
git-compat-util.h:1060:0: warning: "UNIX_PATH_MAX" redefined
#define UNIX_PATH_MAX 92
^
In file included from git-compat-util.h:212:0,
from cache.h:4,
from credential-store.c:1:
/usr/include/sys/un.h:18:0: note: this is the location of the previous definition
#define UNIX_PATH_MAX 108
^
Which is quite easy to confirm:
$ find /usr/include -iname '*.h' | xargs grep -n UNIX_PATH_MAX
/usr/include/sys/un.h:18:#define UNIX_PATH_MAX 108
/usr/include/sys/un.h:22: char sun_path[UNIX_PATH_MAX]; /* 108 bytes of socket address */
$ gcc -dD -E git-compat-util.h 2>/dev/null | grep -n 'un\.h'
8716:# 1 "/usr/include/sys/un.h" 1 3 4
8717:# 12 "/usr/include/sys/un.h" 3 4
$ gcc -dD -E git-compat-util.h 2>/dev/null | grep -n 'UNIX_PATH_MAX'
8724:#define UNIX_PATH_MAX 108
32675:#define UNIX_PATH_MAX 92
$
So, a simple fix would look like:
diff --git a/git-compat-util.h b/git-compat-util.h
index 0e35c13..6d65132 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1043,7 +1043,7 @@ struct tm *git_gmtime_r(const time_t *, struct tm *);
#define getc_unlocked(fh) getc(fh)
#endif
-#ifdef __linux__
+#if defined(__linux__) || defined(__CYGWIN__)
#define UNIX_PATH_MAX 108
#elif defined(__APPLE__) || defined(BSD)
#define UNIX_PATH_MAX 104
... since you are allowed to redefine a macro to the same token sequence
(modulo some strange whitespace rules).
However, assuming the <sys/un.h> header is defining the UNIX_PATH_MAX
macro, why even try to #define it again. So, maybe put an
#ifndef UNIX_PATH_MAX
...
#endif
around the entire block. But then, why on earth are you doing this at all?
Let's look on linux:
$ find /usr/include -iname '*.h' | xargs grep -n UNIX_PATH_MAX
/usr/include/valgrind/vki/vki-linux.h:754:#define VKI_UNIX_PATH_MAX 108
/usr/include/valgrind/vki/vki-linux.h:758: char sun_path[VKI_UNIX_PATH_MAX]; /* pathname */
/usr/include/linux/un.h:6:#define UNIX_PATH_MAX 108
/usr/include/linux/un.h:10: char sun_path[UNIX_PATH_MAX]; /* pathname */
$ gcc -dD -E git-compat-util.h | grep -n 'un\.h'
14119:# 1 "/usr/include/x86_64-linux-gnu/sys/un.h" 1 3 4
14120:# 19 "/usr/include/x86_64-linux-gnu/sys/un.h" 3 4
$ gcc -dD -E git-compat-util.h | grep -n 'UNIX_PATH_MAX'
36788:#define UNIX_PATH_MAX 108
$
Ah, interesting, ... despite having a header that does indeed define the
UNIX_PATH_MAX macro, the compiler is not using that header, but another
one which doesn't. Well, blow me down. ;-)
So, the approach taken by patch #1 is to forget about UNIX_PATH_MAX and
simply use sizeof(address.sun_path) instead!
The second and third patches are simply 'mild suggestions' for other
minor issues I noticed while looking into these warnings.
ATB,
Ramsay Jones
Ramsay Jones (3):
index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
index-helper: convert strncpy to memcpy
index-helper: take extra care with readlink
git-compat-util.h | 17 -----------------
index-helper.c | 4 ++--
read-cache.c | 15 +++++++++++++--
3 files changed, 15 insertions(+), 21 deletions(-)
--
2.8.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
2016-04-10 22:57 [PATCH 0/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin Ramsay Jones
@ 2016-04-11 13:33 ` Jeff King
2016-04-11 21:29 ` David Turner
0 siblings, 1 reply; 4+ messages in thread
From: Jeff King @ 2016-04-11 13:33 UTC (permalink / raw)
To: Ramsay Jones
Cc: David Turner, Nguyen Thai Ngoc Duy, Junio C Hamano, GIT Mailing-list
On Sun, Apr 10, 2016 at 11:57:31PM +0100, Ramsay Jones wrote:
> So, the approach taken by patch #1 is to forget about UNIX_PATH_MAX and
> simply use sizeof(address.sun_path) instead!
That's what the existing code in unix-socket.c does. Which makes me
wonder why the index-helper code is not simply calling that.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
2016-04-11 13:33 ` Jeff King
@ 2016-04-11 21:29 ` David Turner
2016-04-12 1:46 ` Jeff King
0 siblings, 1 reply; 4+ messages in thread
From: David Turner @ 2016-04-11 21:29 UTC (permalink / raw)
To: Jeff King, Ramsay Jones
Cc: Nguyen Thai Ngoc Duy, Junio C Hamano, GIT Mailing-list
On Mon, 2016-04-11 at 09:33 -0400, Jeff King wrote:
> On Sun, Apr 10, 2016 at 11:57:31PM +0100, Ramsay Jones wrote:
>
> > So, the approach taken by patch #1 is to forget about UNIX_PATH_MAX
> > and
> > simply use sizeof(address.sun_path) instead!
>
> That's what the existing code in unix-socket.c does. Which makes me
> wonder why the index-helper code is not simply calling that.
Because I didn't notice it at the time. Duy pointed it out on another
comment on this series; I'll fix it.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin
2016-04-11 21:29 ` David Turner
@ 2016-04-12 1:46 ` Jeff King
0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2016-04-12 1:46 UTC (permalink / raw)
To: David Turner
Cc: Ramsay Jones, Nguyen Thai Ngoc Duy, Junio C Hamano, GIT Mailing-list
On Mon, Apr 11, 2016 at 05:29:22PM -0400, David Turner wrote:
> On Mon, 2016-04-11 at 09:33 -0400, Jeff King wrote:
> > On Sun, Apr 10, 2016 at 11:57:31PM +0100, Ramsay Jones wrote:
> >
> > > So, the approach taken by patch #1 is to forget about UNIX_PATH_MAX
> > > and
> > > simply use sizeof(address.sun_path) instead!
> >
> > That's what the existing code in unix-socket.c does. Which makes me
> > wonder why the index-helper code is not simply calling that.
>
> Because I didn't notice it at the time. Duy pointed it out on another
> comment on this series; I'll fix it.
Thanks. I _think_ it should do everything you need already, but I'm
happy to review any tweaks you need to make to it.
-Peff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-12 1:46 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:57 [PATCH 0/3] index-helper: fix UNIX_PATH_MAX redefinition error on cygwin Ramsay Jones
2016-04-11 13:33 ` Jeff King
2016-04-11 21:29 ` David Turner
2016-04-12 1:46 ` Jeff King
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).