diff options
author | Jeremy Katz <katzj@redhat.com> | 2002-09-24 02:54:23 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2002-09-24 02:54:23 +0000 |
commit | 08677d2b09e3aaa7e1f2f6684244f646695db0b6 (patch) | |
tree | 84b97d789a338c94d2da9aad984d93f0fb00ca07 /loader | |
parent | f4b8a68b0a941638b712a0aec18d41d352995f5e (diff) | |
download | anaconda-08677d2b09e3aaa7e1f2f6684244f646695db0b6.tar.gz anaconda-08677d2b09e3aaa7e1f2f6684244f646695db0b6.tar.xz anaconda-08677d2b09e3aaa7e1f2f6684244f646695db0b6.zip |
ulrich says this is better and less likely to cause problems on platforms
with complicated varargs implementations
Diffstat (limited to 'loader')
-rw-r--r-- | loader/misc.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/loader/misc.c b/loader/misc.c index c7a7d456b..afa815187 100644 --- a/loader/misc.c +++ b/loader/misc.c @@ -71,30 +71,26 @@ int simpleStringCmp(const void * a, const void * b) { char * sdupprintf(const char *format, ...) { char *buf = NULL; char c; - va_list args; + va_list ap1, ap2; size_t size = 0; - va_start(args, format); + va_start(ap1, format); + va_copy(ap1, ap2); /* XXX requires C99 vsnprintf behavior */ - size = vsnprintf(&c, 1, format, args) + 1; + size = vsnprintf(&c, 1, format, ap1) + 1; if (size == -1) { printf("ERROR: vsnprintf behavior is not C99\n"); abort(); } - /* - * according to C99, 7.15 #3, the value of ap is now indeterminate - * so we need to call va_end/va_start again. - */ - va_end(args); - va_start(args, format); + va_end(ap1); buf = malloc(size); if (buf == NULL) return NULL; - vsnprintf(buf, size, format, args); - va_end (args); + vsnprintf(buf, size, format, ap2); + va_end (ap2); return buf; } |