mirror of
https://github.com/torvalds/linux.git
synced 2026-11-26 08:23:17 +00:00
Same problem that got fixed in a similar fashion in tools/perf/ inc8b5f2c96d("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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: David Ahern <[email protected]> Cc: Hendrik Brueckner <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Martin KaFai Lau <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Quentin Monnet <[email protected]> Cc: Thomas Richter <[email protected]> Cc: Wang Nan <[email protected]> Cc: Yonghong Song <[email protected]> Fixes:1ce6a9fc15("bpf: fix build error in libbpf with EXTRA_CFLAGS="-Wp, -D_FORTIFY_SOURCE=2 -O2"") Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
19 lines
479 B
C
19 lines
479 B
C
// 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;
|
|
}
|