diff options
-rw-r--r-- | include/linux/kernel.h | 1 | ||||
-rw-r--r-- | lib/vsprintf.c | 26 |
2 files changed, 20 insertions, 7 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 9ddf25c21538..e2f41b051b12 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -121,6 +121,7 @@ extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) | |||
121 | __attribute__ ((format (printf, 3, 0))); | 121 | __attribute__ ((format (printf, 3, 0))); |
122 | extern char *kasprintf(gfp_t gfp, const char *fmt, ...) | 122 | extern char *kasprintf(gfp_t gfp, const char *fmt, ...) |
123 | __attribute__ ((format (printf, 2, 3))); | 123 | __attribute__ ((format (printf, 2, 3))); |
124 | extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); | ||
124 | 125 | ||
125 | extern int sscanf(const char *, const char *, ...) | 126 | extern int sscanf(const char *, const char *, ...) |
126 | __attribute__ ((format (scanf, 2, 3))); | 127 | __attribute__ ((format (scanf, 2, 3))); |
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b025864d2e43..cbab1df150cf 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -851,23 +851,35 @@ EXPORT_SYMBOL(sscanf); | |||
851 | 851 | ||
852 | 852 | ||
853 | /* Simplified asprintf. */ | 853 | /* Simplified asprintf. */ |
854 | char *kasprintf(gfp_t gfp, const char *fmt, ...) | 854 | char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap) |
855 | { | 855 | { |
856 | va_list ap; | ||
857 | unsigned int len; | 856 | unsigned int len; |
858 | char *p; | 857 | char *p; |
858 | va_list aq; | ||
859 | 859 | ||
860 | va_start(ap, fmt); | 860 | va_copy(aq, ap); |
861 | len = vsnprintf(NULL, 0, fmt, ap); | 861 | len = vsnprintf(NULL, 0, fmt, aq); |
862 | va_end(ap); | 862 | va_end(aq); |
863 | 863 | ||
864 | p = kmalloc(len+1, gfp); | 864 | p = kmalloc(len+1, gfp); |
865 | if (!p) | 865 | if (!p) |
866 | return NULL; | 866 | return NULL; |
867 | va_start(ap, fmt); | 867 | |
868 | vsnprintf(p, len+1, fmt, ap); | 868 | vsnprintf(p, len+1, fmt, ap); |
869 | va_end(ap); | 869 | |
870 | return p; | 870 | return p; |
871 | } | 871 | } |
872 | EXPORT_SYMBOL(kvasprintf); | ||
873 | |||
874 | char *kasprintf(gfp_t gfp, const char *fmt, ...) | ||
875 | { | ||
876 | va_list ap; | ||
877 | char *p; | ||
872 | 878 | ||
879 | va_start(ap, fmt); | ||
880 | p = kvasprintf(gfp, fmt, ap); | ||
881 | va_end(ap); | ||
882 | |||
883 | return p; | ||
884 | } | ||
873 | EXPORT_SYMBOL(kasprintf); | 885 | EXPORT_SYMBOL(kasprintf); |