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

bpf: Remove an unnecessary check.

The "i" here is always equal to "btf_type_vlen(t)" since
the "for_each_member()" loop never breaks.

Signed-off-by: Kui-Feng Lee <thinker.li@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240203055119.2235598-1-thinker.li@gmail.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Kui-Feng Lee and committed by
Martin KaFai Lau
df9705ea 2a79690e

+9 -12
+9 -12
kernel/bpf/bpf_struct_ops.c
··· 189 189 } 190 190 } 191 191 192 - if (i == btf_type_vlen(t)) { 193 - if (st_ops->init(btf)) { 194 - pr_warn("Error in init bpf_struct_ops %s\n", 195 - st_ops->name); 196 - return -EINVAL; 197 - } else { 198 - st_ops_desc->type_id = type_id; 199 - st_ops_desc->type = t; 200 - st_ops_desc->value_id = value_id; 201 - st_ops_desc->value_type = btf_type_by_id(btf, 202 - value_id); 203 - } 192 + if (st_ops->init(btf)) { 193 + pr_warn("Error in init bpf_struct_ops %s\n", 194 + st_ops->name); 195 + return -EINVAL; 204 196 } 197 + 198 + st_ops_desc->type_id = type_id; 199 + st_ops_desc->type = t; 200 + st_ops_desc->value_id = value_id; 201 + st_ops_desc->value_type = btf_type_by_id(btf, value_id); 205 202 206 203 return 0; 207 204 }