mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] perf target: Ignore return value of strerror_r() explicitly
@ 2012-07-03  1:54 Namhyung Kim
  0 siblings, 0 replies; only message in thread
From: Namhyung Kim @ 2012-07-03  1:54 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Peter Zijlstra, Paul Mackerras, Ingo Molnar, LKML,
	Markus Trippelsdorf, Namhyung Kim

From: Namhyung Kim <namhyung.kim@lge.com>

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.

Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/target.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/target.c b/tools/perf/util/target.c
index 1064d5b148ad..c3a38918e8b6 100644
--- a/tools/perf/util/target.c
+++ b/tools/perf/util/target.c
@@ -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;
 	}
 
-- 
1.7.10.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-07-03  1:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-03  1:54 [PATCH v2] perf target: Ignore return value of strerror_r() explicitly Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®