From: Sam Ravnborg <sam@ravnborg.org>
To: Meelis Roos <mroos@linux.ee>, Andrew Morton <akpm@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>,
Richard Henderson <rth@twiddle.net>,
Ivan Kokshaysky <ink@jurassic.park.msu.ru>,
Jay Estabrook <jay.estabrook@hp.com>,
Jeremy Fitzhardinge <jeremy@goop.org>
Subject: [PATCH] lib: move kasprintf to a separate file
Date: Sat, 28 Jul 2007 22:20:12 +0200 [thread overview]
Message-ID: <20070728202012.GB25619@uranus.ravnborg.org> (raw)
In-Reply-To: <20070728200450.GA25619@uranus.ravnborg.org>
kasprintf pulls in kmalloc which proved to be fatal for at least
bootimage target on alpha.
Move it to a separate file so only users of kasprintf are exposed
to the dependency on kmalloc.
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Meelis Roos <mroos@linux.ee>
---
lib/Makefile | 2 +-
lib/kasprintf.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
lib/vsprintf.c | 35 -----------------------------------
3 files changed, 45 insertions(+), 36 deletions(-)
create mode 100644 lib/kasprintf.c
diff --git a/lib/Makefile b/lib/Makefile
index 6149663..d9e5f1c 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -2,7 +2,7 @@
# Makefile for some libs needed in the kernel.
#
-lib-y := ctype.o string.o vsprintf.o cmdline.o \
+lib-y := ctype.o string.o vsprintf.o kasprintf.o cmdline.o \
rbtree.o radix-tree.o dump_stack.o \
idr.o int_sqrt.o bitmap.o extable.o prio_tree.o \
sha1.o irq_regs.o reciprocal_div.o argv_split.o
diff --git a/lib/kasprintf.c b/lib/kasprintf.c
new file mode 100644
index 0000000..c5ff1fd
--- /dev/null
+++ b/lib/kasprintf.c
@@ -0,0 +1,44 @@
+/*
+ * linux/lib/kasprintf.c
+ *
+ * Copyright (C) 1991, 1992 Linus Torvalds
+ */
+
+#include <stdarg.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include <linux/string.h>
+
+/* Simplified asprintf. */
+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)
+ return NULL;
+
+ vsnprintf(p, len+1, fmt, ap);
+
+ return p;
+}
+EXPORT_SYMBOL(kvasprintf);
+
+char *kasprintf(gfp_t gfp, const char *fmt, ...)
+{
+ va_list ap;
+ char *p;
+
+ va_start(ap, fmt);
+ p = kvasprintf(gfp, fmt, ap);
+ va_end(ap);
+
+ return p;
+}
+EXPORT_SYMBOL(kasprintf);
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 6b6734d..7b481ce 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -978,38 +978,3 @@ int sscanf(const char * buf, const char * fmt, ...)
}
EXPORT_SYMBOL(sscanf);
-
-
-/* Simplified asprintf. */
-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)
- return NULL;
-
- vsnprintf(p, len+1, fmt, ap);
-
- return p;
-}
-EXPORT_SYMBOL(kvasprintf);
-
-char *kasprintf(gfp_t gfp, const char *fmt, ...)
-{
- va_list ap;
- char *p;
-
- va_start(ap, fmt);
- p = kvasprintf(gfp, fmt, ap);
- va_end(ap);
-
- return p;
-}
-EXPORT_SYMBOL(kasprintf);
--
1.5.1.rc3.g84b7-dirty
next prev parent reply other threads:[~2007-07-28 20:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-04 11:21 alpha compile failure (srm_printk) Meelis Roos
2007-06-06 6:17 ` Andrew Morton
2007-06-06 7:48 ` Meelis Roos
2007-07-28 17:05 ` Meelis Roos
2007-07-28 20:04 ` Sam Ravnborg
2007-07-28 20:20 ` Sam Ravnborg [this message]
2007-07-28 20:52 ` [PATCH] add a missing LIB_Y to arch/alpha/boot Makefile Meelis Roos
2007-07-28 22:48 ` [PATCH] lib: move kasprintf to a separate file Jeremy Fitzhardinge
2007-07-29 20:08 ` Sam Ravnborg
2007-07-28 20:21 ` alpha compile failure (srm_printk) Sam Ravnborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070728202012.GB25619@uranus.ravnborg.org \
--to=sam@ravnborg.org \
--cc=akpm@linux-foundation.org \
--cc=ink@jurassic.park.msu.ru \
--cc=jay.estabrook@hp.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mroos@linux.ee \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®