Skip to contentSkip to conversation

bpf: remove __btf_name_valid() and change to btf_name_valid_identifier()

PATCH Applied Jeongjun Park 3 participants 3 messages Aug 7, 2024 – Aug 15, 2024 BPF

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: remove __btf_name_valid() and change to btf_name_valid_identifier()

__btf_name_valid() can be completely replaced with btf_name_valid_identifier, and since most of the time you already call btf_name_valid_identifier instead of __btf_name_valid , it would be appropriate to rename the __btf_name_valid function to btf_name_valid_identifier and remove __btf_name_valid.

---
 kernel/bpf/btf.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
kernel/bpf/btf.c +2 -7
index 520f49f422fe..674b38c33c74 100644
@@ -790,7 +790,7 @@ const char *btf_str_by_offset(const struct btf *btf, u32 offset)
 	return NULL;
 }
 
-static bool __btf_name_valid(const struct btf *btf, u32 offset)
+static bool btf_name_valid_identifier(const struct btf *btf, u32 offset)
 {
 	/* offset must be valid */
 	const char *src = btf_str_by_offset(btf, offset);
@@ -811,11 +811,6 @@ static bool __btf_name_valid(const struct btf *btf, u32 offset)
 	return !*src;
 }
 
-static bool btf_name_valid_identifier(const struct btf *btf, u32 offset)
-{
-	return __btf_name_valid(btf, offset);
-}
-
 /* Allow any printable character in DATASEC names */
 static bool btf_name_valid_section(const struct btf *btf, u32 offset)
 {
@@ -4629,7 +4624,7 @@ static s32 btf_var_check_meta(struct btf_verifier_env *env,
 	}
 
 	if (!t->name_off ||
-	    !__btf_name_valid(env->btf, t->name_off)) {
+	    !btf_name_valid_identifier(env->btf, t->name_off)) {
 		btf_verifier_log_type(env, t, "Invalid name");
 		return -EINVAL;
 	}

--

Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Jeongjun Park

__btf_name_valid() can be completely replaced with btf_name_valid_identifier, and since most of the time you already call btf_name_valid_identifier instead of __btf_name_valid , it would be appropriate to rename the __btf_name_valid function to btf_name_valid_identifier and remove __btf_name_valid.

Looks good to me

Quoted 4 lines
---
 kernel/bpf/btf.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
#2 lore raw
In reply to Jeongjun Park
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:

Hello:

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

Quoted 9 lines · On Wed, 7 Aug 2024 23:31:10 +0900 you wrote:

__btf_name_valid() can be completely replaced with btf_name_valid_identifier, and since most of the time you already call btf_name_valid_identifier instead of __btf_name_valid , it would be appropriate to rename the __btf_name_valid function to btf_name_valid_identifier and remove __btf_name_valid.

[...]

Here is the summary with links:
- [bpf-next] bpf: remove __btf_name_valid() and change to btf_name_valid_identifier()

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

You are awesome, thank you!

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