diff options
author | 2018-09-19 13:25:35 +0200 | |
---|---|---|
committer | 2018-09-19 13:25:35 +0200 | |
commit | 5d05dfd13f20b01a3cd5d293058baa7d5c1583b6 (patch) | |
tree | 495ef23dd291a860be093e00b54ff2bcc196476d /tools/lib/bpf/str_error.c | |
parent | Merge tag 'trace-v4.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace (diff) | |
parent | perf Documentation: Fix out-of-tree asciidoctor man page generation (diff) | |
download | linux-dev-5d05dfd13f20b01a3cd5d293058baa7d5c1583b6.tar.xz linux-dev-5d05dfd13f20b01a3cd5d293058baa7d5c1583b6.zip |
Merge tag 'perf-urgent-for-mingo-4.19-20180918' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
- Fix the build on !_GNU_SOURCE libc systems such as Alpine Linux/musl
libc due to usage of strerror_r glibc variant on libbpf (Arnaldo Carvalho de Melo)
- Fix out-of-tree asciidoctor man page generation (Ben Hutchings)
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/lib/bpf/str_error.c')
-rw-r--r-- | tools/lib/bpf/str_error.c | 18 |
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; +} |