diff mbox series

[bpf-next] libbpf: Remove redundant check in btf_fixup_datasec()

Message ID 20220220072750.209215-1-ytcoode@gmail.com (mailing list archive)
State Accepted
Commit 6966d4c4425b6796b1da13a6f86d09825df3d323
Delegated to: BPF
Headers show
Series [bpf-next] libbpf: Remove redundant check in btf_fixup_datasec() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 1 maintainers not CCed: netdev@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next success VM_Test

Commit Message

Yuntao Wang Feb. 20, 2022, 7:27 a.m. UTC
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.

Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
---
 tools/lib/bpf/libbpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrii Nakryiko Feb. 20, 2022, 8:15 p.m. UTC | #1
On Sat, Feb 19, 2022 at 11:29 PM Yuntao Wang <ytcoode@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Yuntao Wang <ytcoode@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 ad43b6ce825e..7e978feaf822 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -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

> +       if (ret || !size) {
>                 pr_debug("Invalid size for section %s: %u bytes\n", name, size);
>                 return -ENOENT;
>         }
> --
> 2.35.1
>
Andrii Nakryiko Feb. 20, 2022, 8:19 p.m. UTC | #2
On Sun, Feb 20, 2022 at 12:15 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Sat, Feb 19, 2022 at 11:29 PM Yuntao Wang <ytcoode@gmail.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Yuntao Wang <ytcoode@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 ad43b6ce825e..7e978feaf822 100644
> > --- a/tools/lib/bpf/libbpf.c
> > +++ b/tools/lib/bpf/libbpf.c
> > @@ -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

ah, never mind :) applied to bpf-next

>
> > +       if (ret || !size) {
> >                 pr_debug("Invalid size for section %s: %u bytes\n", name, size);
> >                 return -ENOENT;
> >         }
> > --
> > 2.35.1
> >
Yuntao Wang Feb. 21, 2022, 4:22 p.m. UTC | #3
On Sun, Feb 20, 2022 at 12:19 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Sun, Feb 20, 2022 at 12:15 PM Andrii Nakryiko
> <andrii.nakryiko@gmail.com> wrote:
>
> > On Sat, Feb 19, 2022 at 11:29 PM Yuntao Wang <ytcoode@gmail.com> wrote:
> > >
> > > 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.
> > >
> > > Signed-off-by: Yuntao Wang <ytcoode@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 ad43b6ce825e..7e978feaf822 100644
> > > --- a/tools/lib/bpf/libbpf.c
> > > +++ b/tools/lib/bpf/libbpf.c
> > > @@ -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
>
> ah, never mind :) applied to bpf-next
>
> >
> > > +       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?
patchwork-bot+netdevbpf@kernel.org Feb. 22, 2022, 10:40 p.m. UTC | #4
Hello:

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

On Sun, 20 Feb 2022 15:27:50 +0800 you wrote:
> 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.
> 
> Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
> ---
>  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!
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index ad43b6ce825e..7e978feaf822 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -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;
 	}