diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-08 14:21:37 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-07-12 14:20:28 -0400 |
commit | c3cec9e68f12d0046f991378391172958b5315d9 (patch) | |
tree | 713ef1e647d5c85dad2702ecbc4f91400af31103 | |
parent | d0761e37fe3fed7810ed8d6e130b79359f0c3e13 (diff) |
tools lib traceevent: Use str_error_r()
To make it portable to non-glibc systems, that follow the XSI variant
instead of the GNU specific one that gets in place when _GNU_SOURCE is
defined.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-c1gn8x978qfop65m510wy43o@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index a8b6357d1ffe..3a7bd175f73c 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <errno.h> | 31 | #include <errno.h> |
32 | #include <stdint.h> | 32 | #include <stdint.h> |
33 | #include <limits.h> | 33 | #include <limits.h> |
34 | #include <linux/string.h> | ||
34 | 35 | ||
35 | #include <netinet/ip6.h> | 36 | #include <netinet/ip6.h> |
36 | #include "event-parse.h" | 37 | #include "event-parse.h" |
@@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused, | |||
6131 | const char *msg; | 6132 | const char *msg; |
6132 | 6133 | ||
6133 | if (errnum >= 0) { | 6134 | if (errnum >= 0) { |
6134 | msg = strerror_r(errnum, buf, buflen); | 6135 | str_error_r(errnum, buf, buflen); |
6135 | if (msg != buf) { | ||
6136 | size_t len = strlen(msg); | ||
6137 | memcpy(buf, msg, min(buflen - 1, len)); | ||
6138 | *(buf + min(buflen - 1, len)) = '\0'; | ||
6139 | } | ||
6140 | return 0; | 6136 | return 0; |
6141 | } | 6137 | } |
6142 | 6138 | ||