-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools lib bpf: Provide wrapper for strerror_r to build in !_GNU_SOURC…
…E systems Same problem that got fixed in a similar fashion in tools/perf/ in c8b5f2c ("tools: Introduce str_error_r()"), fix it in the same way, licensing needs to be sorted out to libbpf to use libapi, so, for this simple case, just get the same wrapper in tools/lib/bpf. This makes libbpf and its users (bpftool, selftests, perf) to build again in Alpine Linux 3.[45678] and edge. Acked-by: Alexei Starovoitov <ast@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Cc: David Ahern <dsahern@gmail.com> Cc: Hendrik Brueckner <brueckner@linux.ibm.com> Cc: Jakub Kicinski <jakub.kicinski@netronome.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Martin KaFai Lau <kafai@fb.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Quentin Monnet <quentin.monnet@netronome.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Wang Nan <wangnan0@huawei.com> Cc: Yonghong Song <yhs@fb.com> Fixes: 1ce6a9f ("bpf: fix build error in libbpf with EXTRA_CFLAGS="-Wp, -D_FORTIFY_SOURCE=2 -O2"") Link: https://lkml.kernel.org/r/20180917151636.GA21790@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
- Loading branch information
Arnaldo Carvalho de Melo
committed
Sep 18, 2018
1 parent
cb48b6a
commit 6d41907
Showing
4 changed files
with
35 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o | ||
libbpf-y := libbpf.o bpf.o nlattr.o btf.o libbpf_errno.o str_error.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// SPDX-License-Identifier: LGPL-2.1 | ||
#ifndef BPF_STR_ERROR | ||
#define BPF_STR_ERROR | ||
|
||
char *str_error(int err, char *dst, int len); | ||
#endif // BPF_STR_ERROR |