libbpf: Remove redundant check in btf_fixup_datasec()
authorYuntao Wang <ytcoode@gmail.com>
Sun, 20 Feb 2022 07:27:50 +0000 (15:27 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 22 Feb 2022 18:50:54 +0000 (10:50 -0800)
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>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220220072750.209215-1-ytcoode@gmail.com
tools/lib/bpf/libbpf.c

index ad43b6c..7e978fe 100644 (file)
@@ -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;
        }