All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec
@ 2020-09-29 22:06 Andrii Nakryiko
  2020-09-29 22:06 ` [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings Andrii Nakryiko
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Andrii Nakryiko @ 2020-09-29 22:06 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Fix obvious unitialized variable use that wasn't reported by compiler. libbpf
Makefile changes to catch such errors are added separately.

Fixes: 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness")
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index e1dbd766c698..398b1f345b3c 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -347,7 +347,7 @@ static int btf_parse_type_sec(struct btf *btf)
 	struct btf_header *hdr = btf->hdr;
 	void *next_type = btf->types_data;
 	void *end_type = next_type + hdr->type_len;
-	int err, i, type_size;
+	int err, i = 0, type_size;
 
 	/* VOID (type_id == 0) is specially handled by btf__get_type_by_id(),
 	 * so ensure we can never properly use its offset from index by
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings
  2020-09-29 22:06 [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Andrii Nakryiko
@ 2020-09-29 22:06 ` Andrii Nakryiko
  2020-09-30  0:03   ` Martin KaFai Lau
  2020-09-29 22:06 ` [PATCH bpf-next 3/3] libbpf: compile in PIC mode only for shared library case Andrii Nakryiko
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2020-09-29 22:06 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

For some reason compiler doesn't complain about uninitialized variable, fixed
in previous patch, if libbpf is compiled without -O2 optimization level. So do
compile it with -O2 and never let similar issue slip by again. -Wall is added
unconditionally, so no need to specify it again.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index f43249696d9f..70cb44efe8cb 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -98,7 +98,7 @@ PC_FILE		= libbpf.pc
 ifdef EXTRA_CFLAGS
   CFLAGS := $(EXTRA_CFLAGS)
 else
-  CFLAGS := -g -Wall
+  CFLAGS := -g -O2
 endif
 
 # Append required CFLAGS
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH bpf-next 3/3] libbpf: compile in PIC mode only for shared library case
  2020-09-29 22:06 [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Andrii Nakryiko
  2020-09-29 22:06 ` [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings Andrii Nakryiko
@ 2020-09-29 22:06 ` Andrii Nakryiko
  2020-09-30  0:04   ` Martin KaFai Lau
  2020-09-30  0:01 ` [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Martin KaFai Lau
  2020-09-30  0:10 ` patchwork-bot+bpf
  3 siblings, 1 reply; 7+ messages in thread
From: Andrii Nakryiko @ 2020-09-29 22:06 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

Libbpf compiles .o's for static and shared library modes separately, so no
need to specify -fPIC for both. Keep it only for shared library mode.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index 70cb44efe8cb..5f9abed3e226 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -104,13 +104,12 @@ endif
 # Append required CFLAGS
 override CFLAGS += $(EXTRA_WARNINGS) -Wno-switch-enum
 override CFLAGS += -Werror -Wall
-override CFLAGS += -fPIC
 override CFLAGS += $(INCLUDES)
 override CFLAGS += -fvisibility=hidden
 override CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 
 # flags specific for shared library
-SHLIB_FLAGS := -DSHARED
+SHLIB_FLAGS := -DSHARED -fPIC
 
 ifeq ($(VERBOSE),1)
   Q =
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec
  2020-09-29 22:06 [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Andrii Nakryiko
  2020-09-29 22:06 ` [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings Andrii Nakryiko
  2020-09-29 22:06 ` [PATCH bpf-next 3/3] libbpf: compile in PIC mode only for shared library case Andrii Nakryiko
@ 2020-09-30  0:01 ` Martin KaFai Lau
  2020-09-30  0:10 ` patchwork-bot+bpf
  3 siblings, 0 replies; 7+ messages in thread
From: Martin KaFai Lau @ 2020-09-30  0:01 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, netdev, ast, daniel, andrii.nakryiko, kernel-team

On Tue, Sep 29, 2020 at 03:06:02PM -0700, Andrii Nakryiko wrote:
> Fix obvious unitialized variable use that wasn't reported by compiler. libbpf
> Makefile changes to catch such errors are added separately.
Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings
  2020-09-29 22:06 ` [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings Andrii Nakryiko
@ 2020-09-30  0:03   ` Martin KaFai Lau
  0 siblings, 0 replies; 7+ messages in thread
From: Martin KaFai Lau @ 2020-09-30  0:03 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, netdev, ast, daniel, andrii.nakryiko, kernel-team

On Tue, Sep 29, 2020 at 03:06:03PM -0700, Andrii Nakryiko wrote:
> For some reason compiler doesn't complain about uninitialized variable, fixed
> in previous patch, if libbpf is compiled without -O2 optimization level. So do
> compile it with -O2 and never let similar issue slip by again. -Wall is added
> unconditionally, so no need to specify it again.
Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 3/3] libbpf: compile in PIC mode only for shared library case
  2020-09-29 22:06 ` [PATCH bpf-next 3/3] libbpf: compile in PIC mode only for shared library case Andrii Nakryiko
@ 2020-09-30  0:04   ` Martin KaFai Lau
  0 siblings, 0 replies; 7+ messages in thread
From: Martin KaFai Lau @ 2020-09-30  0:04 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf, netdev, ast, daniel, andrii.nakryiko, kernel-team

On Tue, Sep 29, 2020 at 03:06:04PM -0700, Andrii Nakryiko wrote:
> Libbpf compiles .o's for static and shared library modes separately, so no
> need to specify -fPIC for both. Keep it only for shared library mode.
Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec
  2020-09-29 22:06 [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Andrii Nakryiko
                   ` (2 preceding siblings ...)
  2020-09-30  0:01 ` [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Martin KaFai Lau
@ 2020-09-30  0:10 ` patchwork-bot+bpf
  3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+bpf @ 2020-09-30  0:10 UTC (permalink / raw)
  To: Andrii Nakryiko; +Cc: bpf

Hello:

This series was applied to bpf/bpf-next.git (refs/heads/master):

On Tue, 29 Sep 2020 15:06:02 -0700 you wrote:
> Fix obvious unitialized variable use that wasn't reported by compiler. libbpf
> Makefile changes to catch such errors are added separately.
> 
> Fixes: 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness")
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
>  tools/lib/bpf/btf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Here is the summary with links:
  - [bpf-next,1/3] libbpf: fix uninitialized variable in btf_parse_type_sec
    https://git.kernel.org/bpf/bpf-next/c/33433913459a
  - [bpf-next,2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings
    https://git.kernel.org/bpf/bpf-next/c/0a62291d697f
  - [bpf-next,3/3] libbpf: compile in PIC mode only for shared library case
    https://git.kernel.org/bpf/bpf-next/c/b0efc216f577

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-09-30  0:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 22:06 [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Andrii Nakryiko
2020-09-29 22:06 ` [PATCH bpf-next 2/3] libbpf: compile libbpf under -O2 level by default and catch extra warnings Andrii Nakryiko
2020-09-30  0:03   ` Martin KaFai Lau
2020-09-29 22:06 ` [PATCH bpf-next 3/3] libbpf: compile in PIC mode only for shared library case Andrii Nakryiko
2020-09-30  0:04   ` Martin KaFai Lau
2020-09-30  0:01 ` [PATCH bpf-next 1/3] libbpf: fix uninitialized variable in btf_parse_type_sec Martin KaFai Lau
2020-09-30  0:10 ` patchwork-bot+bpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.