libbpf: Remove redundant check in btf_fixup_datasec()
PATCH 1/1 libbpf: Remove redundant check in btf_fixup_datasec()
The check 't->size && t->size != size' is redundant because if t->size compares unequal to 0, we will just skip straight to sorting variables.
--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -2795,7 +2795,7 @@ static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, goto sort_vars; ret =find_elf_sec_sz (obj, name, &size); -if (ret || !size || (t->size && t->size != size)) { +if (ret || !size) {pr_debug ("Invalid size for section %s: %u bytes\n" , name, size);return -ENOENT ; }
Signature · 1 line
2.35.1
Quoted 14 lines · Yuntao Wang
The check '
t->size&&t->size!= size' is redundant because ift->sizecompares unequal to 0, we will just skip straight to sorting variables.Signed-off-by Yuntao Wang <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0
tools/lib/bpf/libbpf.c static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, · line 2798
Quoted 4 lines
tools/lib/bpf/libbpf.c +0
-1@@ -2795,7 +2795,7 @@ static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, goto sort_vars; ret =find_elf_sec_sz (obj, name, &size); -if (ret || !size || (t->size && t->size != size)) {
t->size check is redundant, but (t->size != size) is not
Quoted 7 lines
tools/lib/bpf/libbpf.c +1
-1+if (ret || !size) {pr_debug ("Invalid size for section %s: %u bytes\n" , name, size);return -ENOENT ; } --2.35.1
Quoted 18 lines · Andrii Nakryiko
Quoted 16 lines · Yuntao Wang
The check '
t->size&&t->size!= size' is redundant because ift->sizecompares unequal to 0, we will just skip straight to sorting variables.Signed-off-by Yuntao Wang <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0@@ -2795,7 +2795,7 @@ static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, goto sort_vars;
Quoted 4 lines
tools/lib/bpf/libbpf.c static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, · line 2798
Quoted 2 lines
tools/lib/bpf/libbpf.c +0
-1ret =find_elf_sec_sz (obj, name, &size); -if (ret || !size || (t->size && t->size != size)) {
t->sizecheck is redundant, but (t->size!= size) is not
ah, never mind :) applied to bpf-next
Quoted 8 lines
Quoted 8 lines
tools/lib/bpf/libbpf.c +1
-1+if (ret || !size) {pr_debug ("Invalid size for section %s: %u bytes\n" , name, size);return -ENOENT ; } --2.35.1
Quoted 21 lines · Andrii Nakryiko
Quoted 17 lines · Andrii Nakryiko
Quoted 16 lines · Yuntao Wang
The check '
t->size&&t->size!= size' is redundant because ift->sizecompares unequal to 0, we will just skip straight to sorting variables.Signed-off-by Yuntao Wang <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0@@ -2795,7 +2795,7 @@ static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, goto sort_vars;
Quoted 15 lines
Quoted 4 lines
tools/lib/bpf/libbpf.c static int btf_fixup_datasec(struct bpf_object *obj, struct btf *btf, · line 2798
Quoted 2 lines
tools/lib/bpf/libbpf.c +0
-1ret =find_elf_sec_sz (obj, name, &size); -if (ret || !size || (t->size && t->size != size)) {
t->sizecheck is redundant, but (t->size!= size) is notah, never mind :) applied to bpf-next
Quoted 8 lines
Quoted 8 lines
tools/lib/bpf/libbpf.c +1
-1+if (ret || !size) {pr_debug ("Invalid size for section %s: %u bytes\n" , name, size);return -ENOENT ; } --2.35.1
Thanks for your reply.
It seems that the patch has not been applied to bpf-next yet, I can't find it in the commits on the master branch.
Is there anything else I need to do?
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 7 lines · On Sun, 20 Feb 2022 15:27:50 +0800 you wrote:
The check '
t->size&&t->size!= size' is redundant because ift->sizecompares unequal to 0, we will just skip straight to sorting variables.Signed-off-by Yuntao Wang <[email protected]>--- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Here is the summary with links:
- [bpf-next] libbpf: Remove redundant check in btf_fixup_datasec()
https://git.kernel.org/bpf/bpf-next/c/6966d4c4425b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html