* [PATCH bpf-next v2] tools/bpf: make libbpf _GNU_SOURCE friendly
@ 2018-11-29 23:31 Yonghong Song
2018-11-29 23:47 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Yonghong Song @ 2018-11-29 23:31 UTC (permalink / raw)
To: ast, daniel, netdev, jakub.kicinski; +Cc: kernel-team
During porting libbpf to bcc, I got some warnings like below:
...
[ 2%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf.c.o
/home/yhs/work/bcc2/src/cc/libbpf/src/libbpf.c:12:0:
warning: "_GNU_SOURCE" redefined [enabled by default]
#define _GNU_SOURCE
...
[ 3%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf_errno.c.o
/home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c: In function ‘libbpf_strerror’:
/home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c:45:7:
warning: assignment makes integer from pointer without a cast [enabled by default]
ret = strerror_r(err, buf, size);
...
bcc is built with _GNU_SOURCE defined and this caused the above warning.
This patch intends to make libpf _GNU_SOURCE friendly by
. define _GNU_SOURCE in libbpf.c unless it is not defined
. undefine _GNU_SOURCE as non-gnu version of strerror_r is expected.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/lib/bpf/libbpf.c | 2 ++
tools/lib/bpf/libbpf_errno.c | 1 +
2 files changed, 3 insertions(+)
Changelog:
v1 -> v2:
. undef _GNU_SOURCE instead of multiversioning strerror_r,
suggested by Jakub.
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index ed4212a4c5f9..59b748ebd15f 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9,7 +9,9 @@
* Copyright (C) 2017 Nicira, Inc.
*/
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
diff --git a/tools/lib/bpf/libbpf_errno.c b/tools/lib/bpf/libbpf_errno.c
index d83b17f8435c..4343e40588c6 100644
--- a/tools/lib/bpf/libbpf_errno.c
+++ b/tools/lib/bpf/libbpf_errno.c
@@ -7,6 +7,7 @@
* Copyright (C) 2017 Nicira, Inc.
*/
+#undef _GNU_SOURCE
#include <stdio.h>
#include <string.h>
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] tools/bpf: make libbpf _GNU_SOURCE friendly
2018-11-29 23:31 [PATCH bpf-next v2] tools/bpf: make libbpf _GNU_SOURCE friendly Yonghong Song
@ 2018-11-29 23:47 ` Jakub Kicinski
2018-11-30 1:42 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2018-11-29 23:47 UTC (permalink / raw)
To: Yonghong Song; +Cc: ast, daniel, netdev, kernel-team
On Thu, 29 Nov 2018 15:31:45 -0800, Yonghong Song wrote:
> During porting libbpf to bcc, I got some warnings like below:
> ...
> [ 2%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf.c.o
> /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf.c:12:0:
> warning: "_GNU_SOURCE" redefined [enabled by default]
> #define _GNU_SOURCE
> ...
> [ 3%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf_errno.c.o
> /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c: In function ‘libbpf_strerror’:
> /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c:45:7:
> warning: assignment makes integer from pointer without a cast [enabled by default]
> ret = strerror_r(err, buf, size);
> ...
>
> bcc is built with _GNU_SOURCE defined and this caused the above warning.
> This patch intends to make libpf _GNU_SOURCE friendly by
> . define _GNU_SOURCE in libbpf.c unless it is not defined
> . undefine _GNU_SOURCE as non-gnu version of strerror_r is expected.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
FWIW :)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next v2] tools/bpf: make libbpf _GNU_SOURCE friendly
2018-11-29 23:47 ` Jakub Kicinski
@ 2018-11-30 1:42 ` Daniel Borkmann
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-11-30 1:42 UTC (permalink / raw)
To: Jakub Kicinski, Yonghong Song; +Cc: ast, netdev, kernel-team
On 11/30/2018 12:47 AM, Jakub Kicinski wrote:
> On Thu, 29 Nov 2018 15:31:45 -0800, Yonghong Song wrote:
>> During porting libbpf to bcc, I got some warnings like below:
>> ...
>> [ 2%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf.c.o
>> /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf.c:12:0:
>> warning: "_GNU_SOURCE" redefined [enabled by default]
>> #define _GNU_SOURCE
>> ...
>> [ 3%] Building C object src/cc/CMakeFiles/bpf-shared.dir/libbpf/src/libbpf_errno.c.o
>> /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c: In function ‘libbpf_strerror’:
>> /home/yhs/work/bcc2/src/cc/libbpf/src/libbpf_errno.c:45:7:
>> warning: assignment makes integer from pointer without a cast [enabled by default]
>> ret = strerror_r(err, buf, size);
>> ...
>>
>> bcc is built with _GNU_SOURCE defined and this caused the above warning.
>> This patch intends to make libpf _GNU_SOURCE friendly by
>> . define _GNU_SOURCE in libbpf.c unless it is not defined
>> . undefine _GNU_SOURCE as non-gnu version of strerror_r is expected.
>>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>
> FWIW :)
>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-30 12:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-29 23:31 [PATCH bpf-next v2] tools/bpf: make libbpf _GNU_SOURCE friendly Yonghong Song
2018-11-29 23:47 ` Jakub Kicinski
2018-11-30 1:42 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox