rendered paste bodyvasprintf is called like:
int asprintf(char **ptr, const char *format, ...)
{
va_list ap;
int ret;
*ptr = NULL;
va_start(ap, format);
ret = vasprintf(ptr, format, ap);
va_end(ap);
return ret;
}
int vasprintf(char **ptr, const char *format, va_list ap)
{
int ret;
va_list ap2;
VA_COPY(ap2, ap);
ret = vsnprintf(NULL, 0, format, ap2);
if (ret <= 0) return ret;
+va_end (ap2);
(*ptr) = (char *)malloc(ret+1);
if (!*ptr) return -1;
+va_start (ap2, format);
VA_COPY(ap2, ap);
ret = vsnprintf(*ptr, ret+1, format, ap2);
+va_end (ap2);
return ret;
}
Produces on s390 (without modifications), works on x86:
gcc -c -Wall -g -O2 -DHAVE_SNPRINTF -DHAVE_PIPE -DHAVE_STPCPY -D_GNU_SOURCE=1 -o snprintf.o snprintf.c
snprintf.c: In function 'vasprintf':
snprintf.c:856: error: incompatible types in assignment
snprintf.c:864: error: incompatible types in assignment
Produces on x86 (with modifications):
gcc -c -Wall -g -O2 -DHAVE_SNPRINTF -DHAVE_PIPE -DHAVE_STPCPY -D_GNU_SOURCE=1 -o snprintf.o snprintf.c
snprintf.c: In function ‘vasprintf’:
snprintf.c:865: error: ‘va_start’ used in function with fixed args