Re: [PATCH dwarves v1 1/3] btf_encoder: refactor btf_encoder__add_func_proto

Eduard Zingerman
2025-10-30T00:34:39Z

On Wed, 2025-10-29 at 12:02 -0700, Ihor Solodrai wrote:
> btf_encoder__add_func_proto() essentially implements two independent
> code paths depending on input arguments: one for struct ftype and the
> other for struct btf_encoder_func_state.
>
> Split btf_encoder__add_func_proto() into two variants:
> * btf_encoder__add_func_proto_for_ftype()
> * btf_encoder__add_func_proto_for_state()
>
> And factor out common btf_encoder__emit_func_proto() subroutine.
>
> No functional changes.
>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>

Ha, check this out:
https://lore.kernel.org/bpf/18bee370c4804e666eb7d5360c47439c246e1cb7.camel@gmail.com/
Wrote same thing to Alan on Friday :)

> ---
> btf_encoder.c | 135 +++++++++++++++++++++++++++++---------------------
> 1 file changed, 79 insertions(+), 56 deletions(-)
>
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 03bc3c7..0416824 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c

[...]

> +static int32_t btf_encoder__add_func_proto_for_state(struct btf_encoder *encoder, struct btf_encoder_func_state *state)

You can get rid of the `encoder` parameter here.
See https://github.com/acmel/dwarves/commit/080d1f27ae71e30c269a1e26e85bb86c3683f195 . …