1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

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.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2015-07-03 11:16:20 +00:00
parent 424a3f57a2
commit 49557d2481
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285088
2 changed files with 19 additions and 16 deletions

View File

@ -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_ */

View File

@ -715,6 +715,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, ...)
@ -726,7 +743,7 @@ kasprintf(gfp_t gfp, const char *fmt, ...)
p = kvasprintf(gfp, fmt, ap);
va_end(ap);
return p;
return (p);
}
static int