diff options
author | Andrii Nakryiko <andriin@fb.com> | 2019-07-01 19:58:55 -0400 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2019-07-05 16:37:30 -0400 |
commit | d66f43666a6811bcc3e529d5a088e1bdde94ca1b (patch) | |
tree | 28edae2fc3fa048150cf120724f23273e9c24a7c | |
parent | c4cde5804d512a2f8934017dbf7df642dfbdf2ad (diff) |
libbpf: make libbpf_strerror_r agnostic to sign of error
It's often inconvenient to switch sign of error when passing it into
libbpf_strerror_r. It's better for it to handle that automatically.
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r-- | tools/lib/bpf/str_error.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/str_error.c b/tools/lib/bpf/str_error.c index 00e48ac5b806..b8064eedc177 100644 --- a/tools/lib/bpf/str_error.c +++ b/tools/lib/bpf/str_error.c | |||
@@ -11,7 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | char *libbpf_strerror_r(int err, char *dst, int len) | 12 | char *libbpf_strerror_r(int err, char *dst, int len) |
13 | { | 13 | { |
14 | int ret = strerror_r(err, dst, len); | 14 | int ret = strerror_r(err < 0 ? -err : err, dst, len); |
15 | if (ret) | 15 | if (ret) |
16 | snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); | 16 | snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); |
17 | return dst; | 17 | return dst; |