Skip to content

Commit

Permalink
libbpf: Remove several dead assignments
Browse files Browse the repository at this point in the history
Clang Static Analyzer (scan-build) reports several dead assignments in
libbpf where the assigned value is unconditionally overridden by another
value before it is read. Remove these assignments.

Signed-off-by: Viktor Malik <vmalik@redhat.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/5503d18966583e55158471ebbb2f67374b11bf5e.1677658777.git.vmalik@redhat.com
  • Loading branch information
Viktor Malik authored and Andrii Nakryiko committed Mar 1, 2023
1 parent 40e1bca commit 7832d06
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 6 deletions.
2 changes: 0 additions & 2 deletions tools/lib/bpf/btf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1000,8 +1000,6 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
}
}

err = 0;

if (!btf_data) {
pr_warn("failed to find '%s' ELF section in %s\n", BTF_ELF_SEC, path);
err = -ENODATA;
Expand Down
1 change: 0 additions & 1 deletion tools/lib/bpf/libbpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data,
progs = obj->programs;
nr_progs = obj->nr_programs;
nr_syms = symbols->d_size / sizeof(Elf64_Sym);
sec_off = 0;

for (i = 0; i < nr_syms; i++) {
sym = elf_sym_by_idx(obj, i);
Expand Down
3 changes: 0 additions & 3 deletions tools/lib/bpf/relo_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1551,9 +1551,6 @@ int __bpf_core_types_match(const struct btf *local_btf, __u32 local_id, const st
if (level <= 0)
return -EINVAL;

local_t = btf_type_by_id(local_btf, local_id);
targ_t = btf_type_by_id(targ_btf, targ_id);

recur:
depth--;
if (depth < 0)
Expand Down

0 comments on commit 7832d06

Please sign in to comment.