Skip to contentSkip to conversation

bpf: Use ERR_CAST instead of ERR_PTR(PTR_ERR(...))

PATCH Applied Yonghong Song 4 participants 4 messages Jul 20, 2025 – Jul 22, 2025 BPF

lore
Share & tools
lore

Yonghong Song

author reviewer
#0 lore raw

PATCH 1/1 bpf: Use ERR_CAST instead of ERR_PTR(PTR_ERR(...))

Intel linux test robot reported a warning that ERR_CAST can be used for error pointer casting instead of more-complicated/rarely-used ERR_PTR(PTR_ERR(...)) style.

There is no functionality change, but still let us replace two such instances as it improves consistency and readability.

---
 kernel/bpf/cgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/bpf/cgroup.c +2 -2
index 72c8b50dca0a..2e1c0eab20c0 100644
@@ -707,11 +707,11 @@ static struct bpf_prog_list *get_prog_list(struct hlist_head *progs, struct bpf_
 	if (is_link) {
 		anchor_link = bpf_get_anchor_link(flags, id_or_fd);
 		if (IS_ERR(anchor_link))
-			return ERR_PTR(PTR_ERR(anchor_link));
+			return ERR_CAST(anchor_link);
 	} else if (is_id || id_or_fd) {
 		anchor_prog = bpf_get_anchor_prog(flags, id_or_fd);
 		if (IS_ERR(anchor_prog))
-			return ERR_PTR(PTR_ERR(anchor_prog));
+			return ERR_CAST(anchor_prog);
 	}
 
 	if (!anchor_prog && !anchor_link) {
Signature · 1 line
2.47.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Yonghong Song

Intel linux test robot reported a warning that ERR_CAST can be used for error pointer casting instead of more-complicated/rarely-used ERR_PTR(PTR_ERR(...)) style.

There is no functionality change, but still let us replace two such instances as it improves consistency and readability.

---

[...]

#2 lore raw
In reply to Yonghong Song
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 Sun, 20 Jul 2025 09:47:54 -0700 you wrote:

Intel linux test robot reported a warning that ERR_CAST can be used for error pointer casting instead of more-complicated/rarely-used ERR_PTR(PTR_ERR(...)) style.

There is no functionality change, but still let us replace two such instances as it improves consistency and readability.

[...]

Here is the summary with links:
- [bpf-next] bpf: Use ERR_CAST instead of ERR_PTR(PTR_ERR(...))

    https://git.kernel.org/bpf/bpf-next/c/95993dc3039e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Acked-by on v1 1/1
#3 lore raw
In reply to Yonghong Song
Quoted 11 lines · Yonghong Song

Intel linux test robot reported a warning that ERR_CAST can be used for error pointer casting instead of more-complicated/rarely-used ERR_PTR(PTR_ERR(...)) style.

There is no functionality change, but still let us replace two such instances as it improves consistency and readability.

---