On 01/05/2024 18:43, Eduard Zingerman wrote: > On Wed, 2024-05-01 at 18:29 +0100, Alan Maguire wrote: > > [...] > >>>> +/* Check if a member of a split BTF struct/union refers to a base BTF >>>> + * struct/union. Members can be const/restrict/volatile/typedef >>>> + * reference types, but if a pointer is encountered, type is no longer >>>> + * considered embedded. >>>> + */ >>>> +static int btf_find_embedded_composite_type_ids(__u32 *id, void *ctx) >>>> +{ >>>> + struct btf_distill *dist = ctx; >>>> + const struct btf_type *t; >>>> + __u32 next_id = *id; >>>> + >>>> + do { >>>> + if (next_id == 0) >>>> + return 0; >>>> + t = btf_type_by_id(dist->pipe.src, next_id); >>>> + switch (btf_kind(t)) { >>>> + case BTF_KIND_CONST: >>>> + case BTF_KIND_RESTRICT: >>>> + case BTF_KIND_VOLATILE: >>>> + case BTF_KIND_TYPEDEF: >>> >>> I think BTF_KIND_TYPE_TAG is missing. >>> >> >> It's implicit in the default clause; I can't see a case for having a >> split BTF type tag base BTF types, but I might be missing something >> there. I can make all the unexpected types explicit if that would be >> clearer? > > I mean, this skips a series of modifiers, e.g.: > > struct buz { > // next_id will get to 'struct bar' eventually > const volatile struct bar foo; > } > > Now, it is legal to have this chain like below: > > struct buz { > const volatile __type_tag("quux") struct bar foo; > } > > In which case the traversal does not have to stop. > Am I confused? > no, sorry, I was! You're absolutely right, BTF_KIND_TYPE_TAG needs to be accounted for here. Thanks for catching this! > (Note: at the moment type tags are only applied to pointers but that > would change in the future, I have a stalled LLVM change for this). > > [...]