Subject: Re: [RFC/PATCH 1/8] compat: provide a fallback va_copy definition

From: Jonathan Nieder <[email-masked]>
Date: Thu, 24 Feb 2011 14:33:17 -0600

Jeff King wrote:

> So my guess is that this will be sufficient, but I we won't really know
> for sure until somebody reports a problem. :(

Sounds like a good approach to me.

The POSIX rationale hints that some historical implementations used
arrays of size 1.  Assignment would error out on such an
implementation, which is not a big deal (since we could switch to
memcpy then).  I would be more worried about a historical
implementation using dynamic allocation with va_list being a pointer
but I haven't heard of any.

> +#ifndef va_copy
> +#define va_copy(dst,src) (dst) = (src)
> +#endif

The following (as Erik mentinoed) might be a nice cleanup on top.  The
duplicate va_copy definition is just redundant rather than causing
compilation errors because it comes before git-compat-util's
ifndef-guarded one.

diff --git a/compat/msvc.h b/compat/msvc.h
index 023aba0..a33b01c 100644
--- a/compat/msvc.h
+++ b/compat/msvc.h
@@ -9,7 +9,6 @@
 #define inline __inline
 #define __inline__ __inline
 #define __attribute__(x)
-#define va_copy(dst, src)     ((dst) = (src))
 #define strncasecmp  _strnicmp
 #define ftruncate    _chsize