[Bluetooth] Read local version information on device init
[pandora-kernel.git] / lib / vsprintf.c
index f595947..bed7229 100644 (file)
@@ -489,7 +489,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
                if (str < end)
                        *str = '\0';
                else
-                       *end = '\0';
+                       end[-1] = '\0';
        }
        /* the trailing null byte doesn't count towards the total */
        return str-buf;
@@ -849,3 +849,26 @@ int sscanf(const char * buf, const char * fmt, ...)
 }
 
 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);