aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/vsprintf.c26
1 files changed, 19 insertions, 7 deletions
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. */
854char *kasprintf(gfp_t gfp, const char *fmt, ...) 854char *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}
872EXPORT_SYMBOL(kvasprintf);
873
874char *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}
873EXPORT_SYMBOL(kasprintf); 885EXPORT_SYMBOL(kasprintf);