fprintf: Fix recursively printing named structs in --expand_types

In cf459ca16f ("fprintf: Pretty print struct members that are pointers
to nameless structs") we end up breaking 'pahole --expand_types/-E.

All we need there is to print nameless structs when they are referenced
by a pointer member in a struct, i.e. it is defined only there, inline.

Check if that struct is unnamed before emitting it, keeping that fix
while fixing the regression it caused for --expand_types.

Fixes: cf459ca16f ("fprintf: Pretty print struct members that are pointers to nameless structs")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-05-01 12:04:53 -04:00
parent 139a3b3373
commit 68f261d8df
1 changed files with 2 additions and 2 deletions

View File

@ -700,8 +700,8 @@ next_type:
&tconf, fp);
break;
}
if (tag__is_struct(ptype) || tag__is_union(ptype) ||
tag__is_enumeration(ptype)) {
if ((tag__is_struct(ptype) || tag__is_union(ptype) ||
tag__is_enumeration(ptype)) && type__name(tag__type(ptype), cu) == NULL) {
snprintf(namebfptr, sizeof(namebfptr), "* %s", name);
tconf.rel_offset = 1;
name = namebfptr;