Fixed non-standard passing of va_list into functions declared with ...

This commit is contained in:
Jes Bodi Klinke 2016-11-29 11:10:38 -08:00
parent 52e9b3479f
commit 68443abd60

View file

@ -405,12 +405,9 @@ inet_aton(const char *cp, struct in_addr *inp)
#endif #endif
void void
warn(const char *fmt, ...) vwarn(const char *fmt, va_list list)
{ {
va_list list; if (fmt) vfprintf(stderr, fmt, list);
va_start(list, fmt);
if (fmt) fprintf(stderr, fmt, list);
#ifndef ANDROID #ifndef ANDROID
if (errno == 0) { if (errno == 0) {
fprintf(stderr, ": WSA error %d\n", WSAGetLastError()); fprintf(stderr, ": WSA error %d\n", WSAGetLastError());
@ -418,17 +415,32 @@ warn(const char *fmt, ...)
fprintf(stderr, ": %s\n", strerror(errno)); fprintf(stderr, ": %s\n", strerror(errno));
} }
#endif #endif
}
void
warn(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
vwarn(fmt, list);
va_end(list); va_end(list);
} }
void
vwarnx(const char *fmt, va_list list)
{
if (fmt) vfprintf(stderr, fmt, list);
fprintf(stderr, "\n");
}
void void
warnx(const char *fmt, ...) warnx(const char *fmt, ...)
{ {
va_list list; va_list list;
va_start(list, fmt); va_start(list, fmt);
if (fmt) fprintf(stderr, fmt, list); vwarnx(fmt, list);
fprintf(stderr, "\n");
va_end(list); va_end(list);
} }
@ -438,7 +450,7 @@ err(int eval, const char *fmt, ...)
va_list list; va_list list;
va_start(list, fmt); va_start(list, fmt);
warn(fmt, list); vwarn(fmt, list);
va_end(list); va_end(list);
exit(eval); exit(eval);
} }
@ -449,7 +461,7 @@ errx(int eval, const char *fmt, ...)
va_list list; va_list list;
va_start(list, fmt); va_start(list, fmt);
warnx(fmt, list); vwarnx(fmt, list);
va_end(list); va_end(list);
exit(eval); exit(eval);
} }