Skip to contentSkip to conversation

perf target: Ignore return value of strerror_r() explicitly

PATCH New Namhyung Kim 1 participant 1 message Jul 3, 2012 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH v2 1/1 perf target: Ignore return value of strerror_r() explicitly

From: Namhyung Kim <[email protected]>

Since glibc 2.16 added warn_unused_result (wur) attribute to the function, we should check it or ignore it explicitly.

Also resets @buf not to access to garbages for an invalid (negative) @errnum.

---
 tools/perf/util/target.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/target.c +4 -1
index 1064d5b148ad..c3a38918e8b6 100644
@@ -110,8 +110,11 @@ int perf_target__strerror(struct perf_target *target, int errnum,
 	int idx;
 	const char *msg;
 
+	memset(buf, 0, buflen);
+
 	if (errnum >= 0) {
-		strerror_r(errnum, buf, buflen);
+		/* make glibc (>= 2.16) happy */
+		(void)strerror_r(errnum, buf, buflen);
 		return 0;
 	}
 
Signature · 1 line
1.7.10.2