Skip to contentSkip to conversation

kbuild: check return value of asprintf()

PATCH In review Namhyung Kim 3 participants 4 messages Oct 22, 2010 – Oct 27, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: check return value of asprintf()

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

---
The patch is on top of v2.6.36, thanks.

 scripts/basic/docproc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
scripts/basic/docproc.c +4 -1
index fc3b18d..98dec87 100644
@@ -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);
 
Signature · 1 line
1.7.0.4
#1 lore raw

(adding Randy to CC)

Quoted 31 lines · Namhyung Kim

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

---
The patch is on top of v2.6.36, thanks.

 scripts/basic/docproc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
scripts/basic/docproc.c +4 -1
index fc3b18d..98dec87 100644
@@ -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);
 
Acked-by
#2 lore raw
Quoted 1 line · Michal Marek

(adding Randy to CC)

Thanks, Michal.

Quoted 33 lines · Namhyung Kim
Quoted 31 lines

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

---
The patch is on top of v2.6.36, thanks.

 scripts/basic/docproc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
scripts/basic/docproc.c +4 -1
index fc3b18d..98dec87 100644
@@ -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);
 
Signature · 2 lines
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
#3 lore raw
Quoted 6 lines · Randy Dunlap
Quoted 1 line · Michal Marek

(adding Randy to CC)

Thanks, Michal.

OK, applied to kbuild-2.6.git#misc.

Michal

Quoted 37 lines
Quoted 35 lines · Namhyung Kim
Quoted 31 lines

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

---
The patch is on top of v2.6.36, thanks.

 scripts/basic/docproc.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
scripts/basic/docproc.c +4 -1
index fc3b18d..98dec87 100644
@@ -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);