On 11/29/18 1:00 PM, Jakub Kicinski wrote: > On Thu, 29 Nov 2018 12:38:03 -0800, Yonghong Song wrote: >> diff --git a/tools/lib/bpf/libbpf_errno.c b/tools/lib/bpf/libbpf_errno.c >> index d83b17f8435c..286e497c50ec 100644 >> --- a/tools/lib/bpf/libbpf_errno.c >> +++ b/tools/lib/bpf/libbpf_errno.c >> @@ -40,9 +40,19 @@ int libbpf_strerror(int err, char *buf, size_t size) >> err = err > 0 ? err : -err; >> >> if (err < __LIBBPF_ERRNO__START) { >> +#ifdef _GNU_SOURCE >> + const char *ret_buf; >> +#endif >> int ret; >> >> +#ifdef _GNU_SOURCE >> + ret_buf = strerror_r(err, buf, size); >> + if (ret_buf != buf) >> + snprintf(buf, size, "%s", ret_buf); >> + ret = 0; >> +#else >> ret = strerror_r(err, buf, size); >> +#endif >> buf[size - 1] = '\0'; >> return ret; >> } > > That is kinda strange, the whole point for this file was to have > non-GNU strerror_r, would doing #undef _GNU_SOURCE at the top not work?
Thanks for suggestion as I did not the history of this file. Yes, #undef _GNU_SOURCE works. Will send a revision shortly.