Re: [PATCH v2 2/9] bpf/btf: tracing: Move finding func-proto API and getting func-param API to BTF
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date: 2023-07-18 01:02:56
Also in:
bpf, lkml
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Date: 2023-07-18 01:02:56
Also in:
bpf, lkml
On Mon, 17 Jul 2023 19:51:29 -0400 Steven Rostedt [off-list ref] wrote:
On Tue, 18 Jul 2023 08:46:34 +0900 Masami Hiramatsu (Google) [off-list ref] wrote:quoted
quoted
quoted
+ * Get function parameter with the number of parameters. + * This can return NULL if the function has no parameters." It can return EINVAL if this function's parameters are NULL."No, as you can see the code, if btf_type_vlen(func_proto) returns 0 (means the function proto type has no parameters), btf_get_func_param() returns NULL. This is important point because user needs to use IS_ERR_OR_NULL(ret) instead of IS_ERR(ret).I didn't mean to replace what you had, I meant you left that part out. In other words, you have to check for IS_ERR_OR_NULL(ret), not just "!ret".
Ah, got it! Let me update it. Thank you!
-- Stevequoted
quoted
quoted
+ */ +const struct btf_param *btf_get_func_param(const struct btf_type *func_proto, s32 *nr) +{ + if (!func_proto || !nr) + return ERR_PTR(-EINVAL); +
-- Masami Hiramatsu (Google) [off-list ref]