mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-16 13:39:07 +08:00
libbpf: Fixed various checkpatch issues in libbpf.c
Fixed following checkpatch issues:
WARNING: Block comments use a trailing */ on a separate line
+ * other BPF program's BTF object */
WARNING: Possible repeated word: 'be'
+ * name. This is important to be be able to find corresponding BTF
ERROR: switch and case should be at the same indent
+ switch (ext->kcfg.sz) {
+ case 1: *(__u8 *)ext_val = value; break;
+ case 2: *(__u16 *)ext_val = value; break;
+ case 4: *(__u32 *)ext_val = value; break;
+ case 8: *(__u64 *)ext_val = value; break;
+ default:
ERROR: trailing statements should be on next line
+ case 1: *(__u8 *)ext_val = value; break;
ERROR: trailing statements should be on next line
+ case 2: *(__u16 *)ext_val = value; break;
ERROR: trailing statements should be on next line
+ case 4: *(__u32 *)ext_val = value; break;
ERROR: trailing statements should be on next line
+ case 8: *(__u64 *)ext_val = value; break;
ERROR: code indent should use tabs where possible
+ }$
WARNING: please, no spaces at the start of a line
+ }$
WARNING: Block comments use a trailing */ on a separate line
+ * for faster search */
ERROR: code indent should use tabs where possible
+^I^I^I^I^I^I &ext->kcfg.is_signed);$
WARNING: braces {} are not necessary for single statement blocks
+ if (err) {
+ return err;
+ }
ERROR: code indent should use tabs where possible
+^I^I^I^I sizeof(*obj->btf_modules), obj->btf_module_cnt + 1);$
Signed-off-by: Kang Minchul <tegongkang@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20221113190648.38556-3-tegongkang@gmail.com
This commit is contained in:
committed by
Andrii Nakryiko
parent
7b18ff1212
commit
4c3b53d09c
31
src/libbpf.c
31
src/libbpf.c
@@ -347,7 +347,8 @@ enum sec_def_flags {
|
||||
SEC_ATTACHABLE = 2,
|
||||
SEC_ATTACHABLE_OPT = SEC_ATTACHABLE | SEC_EXP_ATTACH_OPT,
|
||||
/* attachment target is specified through BTF ID in either kernel or
|
||||
* other BPF program's BTF object */
|
||||
* other BPF program's BTF object
|
||||
*/
|
||||
SEC_ATTACH_BTF = 4,
|
||||
/* BPF program type allows sleeping/blocking in kernel */
|
||||
SEC_SLEEPABLE = 8,
|
||||
@@ -488,7 +489,7 @@ struct bpf_map {
|
||||
char *name;
|
||||
/* real_name is defined for special internal maps (.rodata*,
|
||||
* .data*, .bss, .kconfig) and preserves their original ELF section
|
||||
* name. This is important to be be able to find corresponding BTF
|
||||
* name. This is important to be able to find corresponding BTF
|
||||
* DATASEC information.
|
||||
*/
|
||||
char *real_name;
|
||||
@@ -1863,10 +1864,18 @@ static int set_kcfg_value_num(struct extern_desc *ext, void *ext_val,
|
||||
return -ERANGE;
|
||||
}
|
||||
switch (ext->kcfg.sz) {
|
||||
case 1: *(__u8 *)ext_val = value; break;
|
||||
case 2: *(__u16 *)ext_val = value; break;
|
||||
case 4: *(__u32 *)ext_val = value; break;
|
||||
case 8: *(__u64 *)ext_val = value; break;
|
||||
case 1:
|
||||
*(__u8 *)ext_val = value;
|
||||
break;
|
||||
case 2:
|
||||
*(__u16 *)ext_val = value;
|
||||
break;
|
||||
case 4:
|
||||
*(__u32 *)ext_val = value;
|
||||
break;
|
||||
case 8:
|
||||
*(__u64 *)ext_val = value;
|
||||
break;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -3518,7 +3527,8 @@ static int bpf_object__elf_collect(struct bpf_object *obj)
|
||||
}
|
||||
|
||||
/* sort BPF programs by section name and in-section instruction offset
|
||||
* for faster search */
|
||||
* for faster search
|
||||
*/
|
||||
if (obj->nr_programs)
|
||||
qsort(obj->programs, obj->nr_programs, sizeof(*obj->programs), cmp_progs);
|
||||
|
||||
@@ -4965,9 +4975,9 @@ bpf_object__reuse_map(struct bpf_map *map)
|
||||
|
||||
err = bpf_map__reuse_fd(map, pin_fd);
|
||||
close(pin_fd);
|
||||
if (err) {
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
|
||||
map->pinned = true;
|
||||
pr_debug("reused pinned map at '%s'\n", map->pin_path);
|
||||
|
||||
@@ -6237,7 +6247,8 @@ bpf_object__reloc_code(struct bpf_object *obj, struct bpf_program *main_prog,
|
||||
* prog; each main prog can have a different set of
|
||||
* subprograms appended (potentially in different order as
|
||||
* well), so position of any subprog can be different for
|
||||
* different main programs */
|
||||
* different main programs
|
||||
*/
|
||||
insn->imm = subprog->sub_insn_off - (prog->sub_insn_off + insn_idx) - 1;
|
||||
|
||||
pr_debug("prog '%s': insn #%zu relocated, imm %d points to subprog '%s' (now at %zu offset)\n",
|
||||
|
||||
Reference in New Issue
Block a user