Skip to content

Commit

Permalink
tools lib traceevent: Use str_error_r()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Jul 12, 2016
1 parent d0761e3 commit c3cec9e
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <errno.h>
#include <stdint.h>
#include <limits.h>
#include <linux/string.h>

#include <netinet/ip6.h>
#include "event-parse.h"
Expand Down Expand Up @@ -6131,12 +6132,7 @@ int pevent_strerror(struct pevent *pevent __maybe_unused,
const char *msg;

if (errnum >= 0) {
msg = strerror_r(errnum, buf, buflen);
if (msg != buf) {
size_t len = strlen(msg);
memcpy(buf, msg, min(buflen - 1, len));
*(buf + min(buflen - 1, len)) = '\0';
}
str_error_r(errnum, buf, buflen);
return 0;
}

Expand Down

0 comments on commit c3cec9e

Please sign in to comment.