.. | .. |
---|
1 | | -// SPDX-License-Identifier: LGPL-2.1 |
---|
| 1 | +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) |
---|
2 | 2 | #undef _GNU_SOURCE |
---|
3 | 3 | #include <string.h> |
---|
4 | 4 | #include <stdio.h> |
---|
5 | 5 | #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 |
---|
6 | 9 | |
---|
7 | 10 | /* |
---|
8 | 11 | * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl |
---|
9 | 12 | * libc, while checking strerror_r() return to avoid having to check this in |
---|
10 | 13 | * all places calling it. |
---|
11 | 14 | */ |
---|
12 | | -char *str_error(int err, char *dst, int len) |
---|
| 15 | +char *libbpf_strerror_r(int err, char *dst, int len) |
---|
13 | 16 | { |
---|
14 | | - int ret = strerror_r(err, dst, len); |
---|
| 17 | + int ret = strerror_r(err < 0 ? -err : err, dst, len); |
---|
15 | 18 | if (ret) |
---|
16 | 19 | snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); |
---|
17 | 20 | return dst; |
---|