* [PATCH v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function.
@ 2025-10-24 8:08 Jianyun Gao
2025-10-28 16:24 ` Yonghong Song
2025-10-28 17:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Jianyun Gao @ 2025-10-24 8:08 UTC (permalink / raw)
To: linux-kernel
Cc: Jianyun Gao, Andrii Nakryiko, Eduard Zingerman,
Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
Hao Luo, Jiri Olsa, open list:BPF [LIBRARY] (libbpf)
In the elf_sec_data() function, the input parameter 'scn' will be
evaluated. If it is NULL, then it will directly return NULL. Therefore,
the return value of the elf_sec_data() function already takes into
account the case where the input parameter scn is NULL. Therefore,
subsequently, the code only needs to check whether the return value of
the elf_sec_data() function is NULL.
Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
---
v1->v2:
Fix the compilation issue caused by rename operation in version v1.
The v1 version is here:
https://lore.kernel.org/lkml/20251024060720.634826-1-jianyungao89@gmail.com/
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b90574f39d1c..fbe74686c97d 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -2996,7 +2996,7 @@ static int bpf_object__init_user_btf_maps(struct bpf_object *obj, bool strict,
scn = elf_sec_by_idx(obj, obj->efile.btf_maps_shndx);
data = elf_sec_data(obj, scn);
- if (!scn || !data) {
+ if (!data) {
pr_warn("elf: failed to get %s map definitions for %s\n",
MAPS_ELF_SEC, obj->path);
return -EINVAL;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function.
2025-10-24 8:08 [PATCH v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function Jianyun Gao
@ 2025-10-28 16:24 ` Yonghong Song
2025-10-28 17:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2025-10-28 16:24 UTC (permalink / raw)
To: Jianyun Gao, linux-kernel
Cc: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
Daniel Borkmann, Martin KaFai Lau, Song Liu, John Fastabend,
KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
open list:BPF [LIBRARY] (libbpf)
On 10/24/25 1:08 AM, Jianyun Gao wrote:
> In the elf_sec_data() function, the input parameter 'scn' will be
> evaluated. If it is NULL, then it will directly return NULL. Therefore,
> the return value of the elf_sec_data() function already takes into
> account the case where the input parameter scn is NULL. Therefore,
> subsequently, the code only needs to check whether the return value of
> the elf_sec_data() function is NULL.
>
> Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function.
2025-10-24 8:08 [PATCH v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function Jianyun Gao
2025-10-28 16:24 ` Yonghong Song
@ 2025-10-28 17:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-28 17:30 UTC (permalink / raw)
To: Jianyun Gao
Cc: linux-kernel, andrii, eddyz87, ast, daniel, martin.lau, song,
yonghong.song, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Fri, 24 Oct 2025 16:08:02 +0800 you wrote:
> In the elf_sec_data() function, the input parameter 'scn' will be
> evaluated. If it is NULL, then it will directly return NULL. Therefore,
> the return value of the elf_sec_data() function already takes into
> account the case where the input parameter scn is NULL. Therefore,
> subsequently, the code only needs to check whether the return value of
> the elf_sec_data() function is NULL.
>
> [...]
Here is the summary with links:
- [v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function.
https://git.kernel.org/bpf/bpf-next/c/4f361895ae65
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] 3+ messages in thread
end of thread, other threads:[~2025-10-28 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 8:08 [PATCH v2] libbpf: optimize the redundant code in the bpf_object__init_user_btf_maps() function Jianyun Gao
2025-10-28 16:24 ` Yonghong Song
2025-10-28 17:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox