summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-06-29 09:52:24 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-06-29 09:52:24 +0000
commit330c369e75932078dde6f4c19c14fd81ce10fc30 (patch)
tree14246acefec878a6b402574b9554425a946313a6
parent2647c278910f305e5b34e24ce8d2d65299a601e8 (diff)
correct vararg use in kasprintf/kvasprintf
fixes names of some encoders
-rw-r--r--sys/dev/pci/drm/include/linux/kernel.h25
1 files changed, 10 insertions, 15 deletions
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;
}