Fix to search a field from the structure which has anonymous union correctly. Since the reference `type` pointer was updated in the loop, the search loop suddenly aborted where it hits an anonymous union. Thus it can not find the field after the anonymous union. This avoids updating the cursor `type` pointer in the loop. Link: https://lore.kernel.org/all/170791694361.389532.10047514554799419688.stgit@devnote2/
Unified · Split
| @@ -91,8 +91,8 @@ retry: · 90 unmodified lines | ||
| 91 | 91 | for_each_member(i, type, member) { |
| 92 | 92 | if (!member->name_off) { |
| 93 | 93 | /* Anonymous union/struct: push it for later use */ |
| 94 | − type = btf_type_skip_modifiers(btf, member->type, &tid); | |
| 95 | − if (type && top < BTF_ANON_STACK_MAX) { | |
| 94 | + if (btf_type_skip_modifiers(btf, member->type, &tid) && | |
| 95 | + top < BTF_ANON_STACK_MAX) { | |
| 96 | 96 | anon_stack[top].tid = tid; |
| 97 | 97 | anon_stack[top++].offset = |
| 98 | 98 | cur_offset + member->offset; |