kbuild: check return value of asprintf()
Namhyung Kim [Fri, 22 Oct 2010 14:32:10 +0000 (23:32 +0900)]
Check return value of asprintf() in docsect() and exit if error
occurs. This removes following warning:

  HOSTCC  scripts/basic/docproc
scripts/basic/docproc.c: In function ‘docsect’:
scripts/basic/docproc.c:336: warning: ignoring return value of ‘asprintf’,
declared with attribute warn_unused_result

Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Michal Marek <mmarek@suse.cz>

scripts/basic/docproc.c

index fc3b18d..98dec87 100644 (file)
@@ -333,7 +333,10 @@ static void docsect(char *filename, char *line)
                if (*s == '\n')
                        *s = '\0';
 
-       asprintf(&s, "DOC: %s", line);
+       if (asprintf(&s, "DOC: %s", line) < 0) {
+               perror("asprintf");
+               exit(1);
+       }
        consume_symbol(s);
        free(s);