[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20181129130023.275d7b39@cakuba.netronome.com>
Date: Thu, 29 Nov 2018 13:00:23 -0800
From: Jakub Kicinski <jakub.kicinski@...ronome.com>
To: Yonghong Song <yhs@...com>
Cc: <ast@...com>, <daniel@...earbox.net>, <netdev@...r.kernel.org>,
<kernel-team@...com>
Subject: Re: [PATCH bpf-next] tools/bpf: make libbpf _GNU_SOURCE friendly
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?
Powered by blists - more mailing lists