diff options
author | 2018-10-04 08:23:03 +0200 | |
---|---|---|
committer | 2018-10-04 08:23:03 +0200 | |
commit | c0554d2d3db438623b4f2f9abc3d766b2b15d2fb (patch) | |
tree | d00dc324772b95373f4bdc566b3437e5bf637157 /tools/lib/bpf/str_error.c | |
parent | lkdtm: Test copy_to_user() on bad kernel pointer under KERNEL_DS (diff) | |
parent | Merge tag 'fbdev-v4.19-rc7' of https://github.com/bzolnier/linux (diff) | |
download | linux-dev-c0554d2d3db438623b4f2f9abc3d766b2b15d2fb.tar.xz linux-dev-c0554d2d3db438623b4f2f9abc3d766b2b15d2fb.zip |
Merge branch 'linus' into x86/core, to pick up fixes
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; +} |