Re: [PATCH bpf-next 06/11] libbpf: ensure btf_dump__new() and btf_dump_opts are future-proof

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Nov 07, 2021 at 10:13:11PM -0800, Andrii Nakryiko wrote:
> +#define btf_dump__new(a1, a2, a3, a4) __builtin_choose_expr(		      \
> +	__builtin_types_compatible_p(typeof(a4), btf_dump_printf_fn_t) +      \
> +	__builtin_types_compatible_p(typeof(a4),			      \
> +				     void(void *, const char *, va_list)),    \
> +	btf_dump__new_deprecated((void *)a1, (void *)a2, (void *)a3, (void *)a4),\
> +	btf_dump__new((void *)a1, (void *)a2, (void *)a3, (void *)a4))

why '+' in the above? The return type of __builtin_types_compatible_p() is bool.
What is bool + bool ?
It suppose to be logical 'OR', right?

Maybe checking for ops type would be more robust ?
Like:
#define btf_dump__new(a1, a2, a3, a4) __builtin_choose_expr(		      \
	__builtin_types_compatible_p(typeof(a4), const struct btf_dump_opts*), \
	btf_dump__new((void *)a1, (void *)a2, (void *)a3, (void *)a4),        \
	btf_dump__new_deprecated((void *)a1, (void *)a2, (void *)a3, (void *)a4))



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux