aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/bpf/str_error.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-09-18 17:20:41 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-09-18 17:20:41 -0300
commit7f16023bfcc4b1f2bbccf86219dc97473db6e0d6 (patch)
tree0abbfba738d76af7a2af067f6c4cec901c2d3c13 /tools/lib/bpf/str_error.c
parentperf/x86/intel/pt: Annotate 'pt_cap_group' with __ro_after_init (diff)
parentperf Documentation: Fix out-of-tree asciidoctor man page generation (diff)
downloadlinux-dev-7f16023bfcc4b1f2bbccf86219dc97473db6e0d6.tar.xz
linux-dev-7f16023bfcc4b1f2bbccf86219dc97473db6e0d6.zip
Merge remote-tracking branch 'acme/perf/urgent' into perf/core
To pick up fixes. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/bpf/str_error.c')
-rw-r--r--tools/lib/bpf/str_error.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/lib/bpf/str_error.c b/tools/lib/bpf/str_error.c
new file mode 100644
index 000000000000..b8798114a357
--- /dev/null
+++ b/tools/lib/bpf/str_error.c
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: LGPL-2.1
+#undef _GNU_SOURCE
+#include <string.h>
+#include <stdio.h>
+#include "str_error.h"
+
+/*
+ * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl
+ * libc, while checking strerror_r() return to avoid having to check this in
+ * all places calling it.
+ */
+char *str_error(int err, char *dst, int len)
+{
+ int ret = strerror_r(err, dst, len);
+ if (ret)
+ snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
+ return dst;
+}