]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
bpf: Remove an unnecessary check.
authorKui-Feng Lee <thinker.li@gmail.com>
Sat, 3 Feb 2024 05:51:19 +0000 (21:51 -0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Mon, 5 Feb 2024 18:25:08 +0000 (10:25 -0800)
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>
kernel/bpf/bpf_struct_ops.c

index 0decd862dfe024768b97edc201234aa51e4d7466..f98f580de77a18b5f61401231eeb2f1b40287141 100644 (file)
@@ -189,20 +189,17 @@ int bpf_struct_ops_desc_init(struct bpf_struct_ops_desc *st_ops_desc,
                }
        }
 
-       if (i == btf_type_vlen(t)) {
-               if (st_ops->init(btf)) {
-                       pr_warn("Error in init bpf_struct_ops %s\n",
-                               st_ops->name);
-                       return -EINVAL;
-               } else {
-                       st_ops_desc->type_id = type_id;
-                       st_ops_desc->type = t;
-                       st_ops_desc->value_id = value_id;
-                       st_ops_desc->value_type = btf_type_by_id(btf,
-                                                                value_id);
-               }
+       if (st_ops->init(btf)) {
+               pr_warn("Error in init bpf_struct_ops %s\n",
+                       st_ops->name);
+               return -EINVAL;
        }
 
+       st_ops_desc->type_id = type_id;
+       st_ops_desc->type = t;
+       st_ops_desc->value_id = value_id;
+       st_ops_desc->value_type = btf_type_by_id(btf, value_id);
+
        return 0;
 }