hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/tools/lib/bpf/str_error.c
....@@ -1,17 +1,20 @@
1
-// SPDX-License-Identifier: LGPL-2.1
1
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
22 #undef _GNU_SOURCE
33 #include <string.h>
44 #include <stdio.h>
55 #include "str_error.h"
6
+
7
+/* make sure libbpf doesn't use kernel-only integer typedefs */
8
+#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
69
710 /*
811 * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl
912 * libc, while checking strerror_r() return to avoid having to check this in
1013 * all places calling it.
1114 */
12
-char *str_error(int err, char *dst, int len)
15
+char *libbpf_strerror_r(int err, char *dst, int len)
1316 {
14
- int ret = strerror_r(err, dst, len);
17
+ int ret = strerror_r(err < 0 ? -err : err, dst, len);
1518 if (ret)
1619 snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
1720 return dst;