bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libbpf: Initialize err in probe_map_create
@ 2022-08-01  2:51 Florian Fainelli
  2022-08-01 16:25 ` Jiri Olsa
  2022-08-04 21:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 4+ messages in thread
From: Florian Fainelli @ 2022-08-01  2:51 UTC (permalink / raw)
  To: bpf
  Cc: Florian Fainelli, Andrii Nakryiko, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Dave Marchevsky, open list

GCC-11 warns about the possibly unitialized err variable in
probe_map_create:

libbpf_probes.c: In function 'probe_map_create':
libbpf_probes.c:361:38: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  361 |                 return fd < 0 && err == exp_err ? 1 : 0;
      |                                  ~~~~^~~~~~~~~~

Fixes: 878d8def0603 ("libbpf: Rework feature-probing APIs")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 tools/lib/bpf/libbpf_probes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c
index 97b06cede56f..6cf44e61815d 100644
--- a/tools/lib/bpf/libbpf_probes.c
+++ b/tools/lib/bpf/libbpf_probes.c
@@ -247,7 +247,7 @@ static int probe_map_create(enum bpf_map_type map_type, __u32 ifindex)
 	LIBBPF_OPTS(bpf_map_create_opts, opts);
 	int key_size, value_size, max_entries;
 	__u32 btf_key_type_id = 0, btf_value_type_id = 0;
-	int fd = -1, btf_fd = -1, fd_inner = -1, exp_err = 0, err;
+	int fd = -1, btf_fd = -1, fd_inner = -1, exp_err = 0, err = 0;
 
 	opts.map_ifindex = ifindex;
 
-- 
2.25.1


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

* Re: [PATCH] libbpf: Initialize err in probe_map_create
  2022-08-01  2:51 [PATCH] libbpf: Initialize err in probe_map_create Florian Fainelli
@ 2022-08-01 16:25 ` Jiri Olsa
  2022-08-04 21:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Olsa @ 2022-08-01 16:25 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: bpf, Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Dave Marchevsky,
	open list

On Sun, Jul 31, 2022 at 07:51:09PM -0700, Florian Fainelli wrote:
> GCC-11 warns about the possibly unitialized err variable in
> probe_map_create:
> 
> libbpf_probes.c: In function 'probe_map_create':
> libbpf_probes.c:361:38: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   361 |                 return fd < 0 && err == exp_err ? 1 : 0;
>       |                                  ~~~~^~~~~~~~~~
> 
> Fixes: 878d8def0603 ("libbpf: Rework feature-probing APIs")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  tools/lib/bpf/libbpf_probes.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/lib/bpf/libbpf_probes.c b/tools/lib/bpf/libbpf_probes.c
> index 97b06cede56f..6cf44e61815d 100644
> --- a/tools/lib/bpf/libbpf_probes.c
> +++ b/tools/lib/bpf/libbpf_probes.c
> @@ -247,7 +247,7 @@ static int probe_map_create(enum bpf_map_type map_type, __u32 ifindex)
>  	LIBBPF_OPTS(bpf_map_create_opts, opts);
>  	int key_size, value_size, max_entries;
>  	__u32 btf_key_type_id = 0, btf_value_type_id = 0;
> -	int fd = -1, btf_fd = -1, fd_inner = -1, exp_err = 0, err;
> +	int fd = -1, btf_fd = -1, fd_inner = -1, exp_err = 0, err = 0;
>  
>  	opts.map_ifindex = ifindex;
>  
> -- 
> 2.25.1
> 

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

* Re: [PATCH] libbpf: Initialize err in probe_map_create
  2022-08-01  2:51 [PATCH] libbpf: Initialize err in probe_map_create Florian Fainelli
  2022-08-01 16:25 ` Jiri Olsa
@ 2022-08-04 21:50 ` patchwork-bot+netdevbpf
  2022-08-31 21:50   ` Florian Fainelli
  1 sibling, 1 reply; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-04 21:50 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: bpf, andrii, ast, daniel, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, davemarchevsky, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Sun, 31 Jul 2022 19:51:09 -0700 you wrote:
> GCC-11 warns about the possibly unitialized err variable in
> probe_map_create:
> 
> libbpf_probes.c: In function 'probe_map_create':
> libbpf_probes.c:361:38: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   361 |                 return fd < 0 && err == exp_err ? 1 : 0;
>       |                                  ~~~~^~~~~~~~~~
> 
> [...]

Here is the summary with links:
  - libbpf: Initialize err in probe_map_create
    https://git.kernel.org/bpf/bpf-next/c/3045f42a6432

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] 4+ messages in thread

* Re: [PATCH] libbpf: Initialize err in probe_map_create
  2022-08-04 21:50 ` patchwork-bot+netdevbpf
@ 2022-08-31 21:50   ` Florian Fainelli
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Fainelli @ 2022-08-31 21:50 UTC (permalink / raw)
  To: patchwork-bot+netdevbpf
  Cc: bpf, andrii, ast, daniel, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa, davemarchevsky, linux-kernel



On 8/4/2022 2:50 PM, patchwork-bot+netdevbpf@kernel.org wrote:
> Hello:
> 
> This patch was applied to bpf/bpf-next.git (master)
> by Andrii Nakryiko <andrii@kernel.org>:
> 
> On Sun, 31 Jul 2022 19:51:09 -0700 you wrote:
>> GCC-11 warns about the possibly unitialized err variable in
>> probe_map_create:
>>
>> libbpf_probes.c: In function 'probe_map_create':
>> libbpf_probes.c:361:38: error: 'err' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>>    361 |                 return fd < 0 && err == exp_err ? 1 : 0;
>>        |                                  ~~~~^~~~~~~~~~
>>
>> [...]
> 
> Here is the summary with links:
>    - libbpf: Initialize err in probe_map_create
>      https://git.kernel.org/bpf/bpf-next/c/3045f42a6432
> 
> You are awesome, thank you!

Thanks for applying, I was sort of expecting this patch to land to Linus 
a bit quicker, as far as I can see it is still only in linux-next yet it 
does fix a build warning turned error. Any chance of fast tracking it?

Thanks!
-- 
Florian

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

end of thread, other threads:[~2022-08-31 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-01  2:51 [PATCH] libbpf: Initialize err in probe_map_create Florian Fainelli
2022-08-01 16:25 ` Jiri Olsa
2022-08-04 21:50 ` patchwork-bot+netdevbpf
2022-08-31 21:50   ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).