Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Jul 2015 11:16:21 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r285088 - head/sys/ofed/include/linux
Message-ID:  <201507031116.t63BGLjO046575@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Fri Jul  3 11:16:20 2015
New Revision: 285088
URL: https://svnweb.freebsd.org/changeset/base/285088

Log:
  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

Modified:
  head/sys/ofed/include/linux/device.h
  head/sys/ofed/include/linux/linux_compat.c

Modified: head/sys/ofed/include/linux/device.h
==============================================================================
--- head/sys/ofed/include/linux/device.h	Fri Jul  3 11:02:20 2015	(r285087)
+++ head/sys/ofed/include/linux/device.h	Fri Jul  3 11:16:20 2015	(r285088)
@@ -416,21 +416,7 @@ static inline int dev_to_node(struct 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_ */

Modified: head/sys/ofed/include/linux/linux_compat.c
==============================================================================
--- head/sys/ofed/include/linux/linux_compat.c	Fri Jul  3 11:02:20 2015	(r285087)
+++ head/sys/ofed/include/linux/linux_compat.c	Fri Jul  3 11:16:20 2015	(r285088)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507031116.t63BGLjO046575>