diff options
author | 2018-11-12 09:07:41 -0800 | |
---|---|---|
committer | 2018-11-12 09:07:41 -0800 | |
commit | 26b76320a8a550472bbb8f42257df83fcb8d8df6 (patch) | |
tree | 8a5b569f4f070bf4971e24e7fccfe3004b8fc4ba /tools/lib/bpf/str_error.c | |
parent | tomoyo: fix small typo (diff) | |
parent | Linux 4.20-rc2 (diff) | |
download | linux-dev-26b76320a8a550472bbb8f42257df83fcb8d8df6.tar.xz linux-dev-26b76320a8a550472bbb8f42257df83fcb8d8df6.zip |
Merge tag 'v4.20-rc2' into next-general
Sync to Linux 4.20-rc2 for downstream developers.
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..00e48ac5b806 --- /dev/null +++ b/tools/lib/bpf/str_error.c @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +#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 *libbpf_strerror_r(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; +} |