Commit d66f4366 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Daniel Borkmann

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: default avatarAndrii Nakryiko <andriin@fb.com>
Reviewed-by: default avatarStanislav Fomichev <sdf@google.com>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent c4cde580
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
*/ */
char *libbpf_strerror_r(int err, char *dst, int len) char *libbpf_strerror_r(int err, char *dst, int len)
{ {
int ret = strerror_r(err, dst, len); int ret = strerror_r(err < 0 ? -err : err, dst, len);
if (ret) if (ret)
snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret); snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
return dst; return dst;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment