LCOV - code coverage report
Current view: top level - lib - kasprintf.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 13 13 100.0 %
Date: 2015-04-12 14:34:49 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :  *  linux/lib/kasprintf.c
       3             :  *
       4             :  *  Copyright (C) 1991, 1992  Linus Torvalds
       5             :  */
       6             : 
       7             : #include <stdarg.h>
       8             : #include <linux/export.h>
       9             : #include <linux/slab.h>
      10             : #include <linux/types.h>
      11             : #include <linux/string.h>
      12             : 
      13             : /* Simplified asprintf. */
      14        2061 : char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
      15             : {
      16             :         unsigned int len;
      17             :         char *p;
      18             :         va_list aq;
      19             : 
      20        2061 :         va_copy(aq, ap);
      21        2061 :         len = vsnprintf(NULL, 0, fmt, aq);
      22        2061 :         va_end(aq);
      23             : 
      24        2061 :         p = kmalloc_track_caller(len+1, gfp);
      25        2061 :         if (!p)
      26             :                 return NULL;
      27             : 
      28        2061 :         vsnprintf(p, len+1, fmt, ap);
      29             : 
      30        2061 :         return p;
      31             : }
      32             : EXPORT_SYMBOL(kvasprintf);
      33             : 
      34        1317 : char *kasprintf(gfp_t gfp, const char *fmt, ...)
      35             : {
      36             :         va_list ap;
      37             :         char *p;
      38             : 
      39        1317 :         va_start(ap, fmt);
      40        1317 :         p = kvasprintf(gfp, fmt, ap);
      41        1317 :         va_end(ap);
      42             : 
      43        1317 :         return p;
      44             : }
      45             : EXPORT_SYMBOL(kasprintf);

Generated by: LCOV version 1.11