+ implement-kasprintf.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     Implement kasprintf

has been added to the -mm tree.  Its filename is

     implement-kasprintf.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: Implement kasprintf
From: Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx>


Implement kasprintf, a kernel version of asprintf.  This allocates the
memory required for the formatted string, including the trailing '\0'. 
Returns NULL on allocation failure.

Signed-off-by: Jeremy Fitzhardinge <jeremy@xxxxxxxxxxxxx>
Signed-off-by: Chris Wright <chrisw@xxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 include/linux/kernel.h |    2 ++
 lib/vsprintf.c         |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff -puN include/linux/kernel.h~implement-kasprintf include/linux/kernel.h
--- 25/include/linux/kernel.h~implement-kasprintf	Tue Jun 20 17:54:53 2006
+++ 25-akpm/include/linux/kernel.h	Tue Jun 20 17:54:53 2006
@@ -119,6 +119,8 @@ extern int scnprintf(char * buf, size_t 
 	__attribute__ ((format (printf, 3, 4)));
 extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
 	__attribute__ ((format (printf, 3, 0)));
+extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
+	__attribute__ ((format (printf, 2, 3)));
 
 extern int sscanf(const char *, const char *, ...)
 	__attribute__ ((format (scanf, 2, 3)));
diff -puN lib/vsprintf.c~implement-kasprintf lib/vsprintf.c
--- 25/lib/vsprintf.c~implement-kasprintf	Tue Jun 20 17:54:53 2006
+++ 25-akpm/lib/vsprintf.c	Tue Jun 20 17:54:53 2006
@@ -849,3 +849,26 @@ int sscanf(const char * buf, const char 
 }
 
 EXPORT_SYMBOL(sscanf);
+
+
+/* Simplified asprintf. */
+char *kasprintf(gfp_t gfp, const char *fmt, ...)
+{
+	va_list ap;
+	unsigned int len;
+	char *p;
+
+	va_start(ap, fmt);
+	len = vsnprintf(NULL, 0, fmt, ap);
+	va_end(ap);
+
+	p = kmalloc(len+1, gfp);
+	if (!p)
+		return NULL;
+	va_start(ap, fmt);
+	vsnprintf(p, len+1, fmt, ap);
+	va_end(ap);
+	return p;
+}
+
+EXPORT_SYMBOL(kasprintf);
_

Patches currently in -mm which might be from jeremy@xxxxxxxxxxxxx are

clean-up-and-refactor-i386-sub-architecture-setup.patch
fix-bounds-check-in-vsnprintf-to-allow-for-a-0-size-and.patch
fix-bounds-check-in-vsnprintf-to-allow-for-a-0-size-and-tidy.patch
implement-kasprintf.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux