Skip to contentSkip to conversation

bpf: Remove an unnecessary check.

PATCH Applied [email protected] 3 participants 3 messages Feb 3, 2024 – Feb 5, 2024 BPF

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: Remove an unnecessary check.

From: Kui-Feng Lee <[email protected]>

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

---
 kernel/bpf/bpf_struct_ops.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
kernel/bpf/bpf_struct_ops.c +9 -12
index 0decd862dfe0..f98f580de77a 100644
@@ -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;
 }
 
Signature · 1 line
2.34.1
#2 lore raw
In reply to [email protected]
This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Martin KaFai Lau <[email protected]>:

Quoted 8 lines · On Fri, 2 Feb 2024 21:51:19 -0800 you wrote:

From: Kui-Feng Lee <[email protected]>

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

[...]

Here is the summary with links:
- [bpf-next] bpf: Remove an unnecessary check.

    https://git.kernel.org/bpf/bpf-next/c/df9705eaa0ba

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html