Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'libbpf: fix several issues reported by static analysers'

Viktor Malik says:

====================

Fixing several issues reported by Coverity and Clang Static Analyzer
(scan-build) for libbpf, mostly removing unnecessary symbols and
assignments.

No functional changes should be introduced.
====================

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

+3 -16
-2
tools/lib/bpf/btf.c
··· 1000 1000 } 1001 1001 } 1002 1002 1003 - err = 0; 1004 - 1005 1003 if (!btf_data) { 1006 1004 pr_warn("failed to find '%s' ELF section in %s\n", BTF_ELF_SEC, path); 1007 1005 err = -ENODATA;
+1 -2
tools/lib/bpf/libbpf.c
··· 798 798 progs = obj->programs; 799 799 nr_progs = obj->nr_programs; 800 800 nr_syms = symbols->d_size / sizeof(Elf64_Sym); 801 - sec_off = 0; 802 801 803 802 for (i = 0; i < nr_syms; i++) { 804 803 sym = elf_sym_by_idx(obj, i); ··· 2614 2615 strict = !OPTS_GET(opts, relaxed_maps, false); 2615 2616 pin_root_path = OPTS_GET(opts, pin_root_path, NULL); 2616 2617 2617 - err = err ?: bpf_object__init_user_btf_maps(obj, strict, pin_root_path); 2618 + err = bpf_object__init_user_btf_maps(obj, strict, pin_root_path); 2618 2619 err = err ?: bpf_object__init_global_data_maps(obj); 2619 2620 err = err ?: bpf_object__init_kconfig_map(obj); 2620 2621 err = err ?: bpf_object__init_struct_ops_maps(obj);
+2 -9
tools/lib/bpf/linker.c
··· 1997 1997 static int linker_append_elf_relos(struct bpf_linker *linker, struct src_obj *obj) 1998 1998 { 1999 1999 struct src_sec *src_symtab = &obj->secs[obj->symtab_sec_idx]; 2000 - struct dst_sec *dst_symtab; 2001 2000 int i, err; 2002 2001 2003 2002 for (i = 1; i < obj->sec_cnt; i++) { ··· 2029 2030 return -1; 2030 2031 } 2031 2032 2032 - /* add_dst_sec() above could have invalidated linker->secs */ 2033 - dst_symtab = &linker->secs[linker->symtab_sec_idx]; 2034 - 2035 2033 /* shdr->sh_link points to SYMTAB */ 2036 2034 dst_sec->shdr->sh_link = linker->symtab_sec_idx; 2037 2035 ··· 2045 2049 dst_rel = dst_sec->raw_data + src_sec->dst_off; 2046 2050 n = src_sec->shdr->sh_size / src_sec->shdr->sh_entsize; 2047 2051 for (j = 0; j < n; j++, src_rel++, dst_rel++) { 2048 - size_t src_sym_idx = ELF64_R_SYM(src_rel->r_info); 2049 - size_t sym_type = ELF64_R_TYPE(src_rel->r_info); 2050 - Elf64_Sym *src_sym, *dst_sym; 2051 - size_t dst_sym_idx; 2052 + size_t src_sym_idx, dst_sym_idx, sym_type; 2053 + Elf64_Sym *src_sym; 2052 2054 2053 2055 src_sym_idx = ELF64_R_SYM(src_rel->r_info); 2054 2056 src_sym = src_symtab->data->d_buf + sizeof(*src_sym) * src_sym_idx; 2055 2057 2056 2058 dst_sym_idx = obj->sym_map[src_sym_idx]; 2057 - dst_sym = dst_symtab->raw_data + sizeof(*dst_sym) * dst_sym_idx; 2058 2059 dst_rel->r_offset += src_linked_sec->dst_off; 2059 2060 sym_type = ELF64_R_TYPE(src_rel->r_info); 2060 2061 dst_rel->r_info = ELF64_R_INFO(dst_sym_idx, sym_type);
-3
tools/lib/bpf/relo_core.c
··· 1551 1551 if (level <= 0) 1552 1552 return -EINVAL; 1553 1553 1554 - local_t = btf_type_by_id(local_btf, local_id); 1555 - targ_t = btf_type_by_id(targ_btf, targ_id); 1556 - 1557 1554 recur: 1558 1555 depth--; 1559 1556 if (depth < 0)