diff options
author | hselasky <hselasky@FreeBSD.org> | 2015-07-11 21:59:15 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2015-07-11 21:59:15 +0000 |
commit | e70b377190082d9d101ccea4d2282c3e18c16cc6 (patch) | |
tree | d3b25740e2d2f055d67744d9fa1cf90f9340fe00 /sys/ofed | |
parent | 969c638bab6fb75c02ed90c0ce3b115fbd437d52 (diff) | |
download | FreeBSD-src-e70b377190082d9d101ccea4d2282c3e18c16cc6.zip FreeBSD-src-e70b377190082d9d101ccea4d2282c3e18c16cc6.tar.gz |
MFC r285088:
Fix broken implementation of "kvasprintf()" function by adding missing
kmalloc() call. Make function global instead of static inline to fix
compiler warnings about passing variable argument lists to inline
functions.
Sponsored by: Mellanox Technologies
Approved by: re, gjb
Diffstat (limited to 'sys/ofed')
-rw-r--r-- | sys/ofed/include/linux/device.h | 16 | ||||
-rw-r--r-- | sys/ofed/include/linux/linux_compat.c | 19 |
2 files changed, 19 insertions, 16 deletions
diff --git a/sys/ofed/include/linux/device.h b/sys/ofed/include/linux/device.h index 87cf0e8..b7795fc 100644 --- a/sys/ofed/include/linux/device.h +++ b/sys/ofed/include/linux/device.h @@ -416,21 +416,7 @@ static inline int dev_to_node(struct device *dev) return -1; } -static inline char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) -{ - unsigned int len; - char *p = NULL; - va_list aq; - - va_copy(aq, ap); - len = vsnprintf(NULL, 0, fmt, aq); - va_end(aq); - - vsnprintf(p, len+1, fmt, ap); - - return p; -} - +char *kvasprintf(gfp_t, const char *, va_list); char *kasprintf(gfp_t, const char *, ...); #endif /* _LINUX_DEVICE_H_ */ diff --git a/sys/ofed/include/linux/linux_compat.c b/sys/ofed/include/linux/linux_compat.c index 986f0a6..f428fc8 100644 --- a/sys/ofed/include/linux/linux_compat.c +++ b/sys/ofed/include/linux/linux_compat.c @@ -691,6 +691,23 @@ vunmap(void *addr) kfree(vmmap); } +char * +kvasprintf(gfp_t gfp, const char *fmt, va_list ap) +{ + unsigned int len; + char *p; + va_list aq; + + va_copy(aq, ap); + len = vsnprintf(NULL, 0, fmt, aq); + va_end(aq); + + p = kmalloc(len + 1, gfp); + if (p != NULL) + vsnprintf(p, len + 1, fmt, ap); + + return (p); +} char * kasprintf(gfp_t gfp, const char *fmt, ...) @@ -702,7 +719,7 @@ kasprintf(gfp_t gfp, const char *fmt, ...) p = kvasprintf(gfp, fmt, ap); va_end(ap); - return p; + return (p); } static int |