From: jsg Date: Wed, 29 Jun 2022 09:52:23 +0000 (+0000) Subject: correct vararg use in kasprintf/kvasprintf X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=bfffe9a4da971de550039b51ab683dc06437cc13;p=openbsd correct vararg use in kasprintf/kvasprintf fixes names of some encoders --- diff --git a/sys/dev/pci/drm/include/linux/kernel.h b/sys/dev/pci/drm/include/linux/kernel.h index 34248ad3709..6f0ab4f58f0 100644 --- a/sys/dev/pci/drm/include/linux/kernel.h +++ b/sys/dev/pci/drm/include/linux/kernel.h @@ -83,38 +83,33 @@ #define PTR_ALIGN(x, y) ((__typeof(x))roundup2((unsigned long)(x), (y))) static inline char * -kasprintf(int flags, const char *fmt, ...) +kvasprintf(int flags, const char *fmt, va_list ap) { char *buf; size_t len; - va_list ap; + va_list vl; - va_start(ap, fmt); - len = vsnprintf(NULL, 0, fmt, ap); - va_end(ap); + va_copy(vl, ap); + len = vsnprintf(NULL, 0, fmt, vl); + va_end(vl); buf = malloc(len + 1, M_DRM, flags); if (buf) { - va_start(ap, fmt); vsnprintf(buf, len + 1, fmt, ap); - va_end(ap); } return buf; } static inline char * -kvasprintf(int flags, const char *fmt, va_list ap) +kasprintf(int flags, const char *fmt, ...) { char *buf; - size_t len; - - len = vsnprintf(NULL, 0, fmt, ap); + va_list ap; - buf = malloc(len + 1, M_DRM, flags); - if (buf) { - vsnprintf(buf, len + 1, fmt, ap); - } + va_start(ap, fmt); + buf = kvasprintf(flags, fmt, ap); + va_end(ap); return buf; }