From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Se one case where a struct has embedded flexible arrays, that was not being notified as comments following those members: acme@x1:~/git/pahole$ pahole lirc_fh struct lirc_fh { struct list_head list; /* 0 16 */ struct rc_dev * rc; /* 16 8 */ int carrier_low; /* 24 4 */ /* XXX 4 bytes hole, try to pack */ struct { union { struct __kfifo kfifo; /* 32 24 */ unsigned int * type; /* 32 8 */ const unsigned int * const_type; /* 32 8 */ char * rectype; /* 32 8 */ unsigned int * ptr; /* 32 8 */ const unsigned int * ptr_const; /* 32 8 */ }; /* 32 24 */ unsigned int buf[]; /* 56 0 */ } rawir; /* 32 24 */ /* XXX last struct has a flexible array */ struct { union { struct __kfifo kfifo; /* 56 24 */ struct lirc_scancode * type; /* 56 8 */ const struct lirc_scancode * const_type; /* 56 8 */ char * rectype; /* 56 8 */ struct lirc_scancode * ptr; /* 56 8 */ const struct lirc_scancode * ptr_const; /* 56 8 */ }; /* 56 24 */ /* --- cacheline 1 boundary (64 bytes) was 16 bytes ago --- */ struct lirc_scancode buf[]; /* 80 0 */ } scancodes; /* 56 24 */ /* XXX last struct has a flexible array */ wait_queue_head_t wait_poll; /* 80 24 */ u8 send_mode; /* 104 1 */ u8 rec_mode; /* 105 1 */ /* size: 112, cachelines: 2, members: 8 */ /* sum members: 102, holes: 1, sum holes: 4 */ /* padding: 6 */ /* last cacheline: 48 bytes */ }; Now we need to count how many embedded flexible arrays are in a struct to print at the end stats, right before that "last cacheline:" comment line. Cc: "Gustavo A. R. Silva" <gustavoars@xxxxxxxxxx> Cc: Willy Tarreau <w@xxxxxx> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> --- dwarves_fprintf.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index 94a152183b0725cf..0d642a318fd836ef 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -1513,7 +1513,7 @@ static size_t class__fprintf_member_type_holes(struct class *class, const struct size_t printed = 0; uint16_t padding; uint8_t nr_holes, nr_bit_holes, bit_padding; - bool first = true, has_embedded_flexible_array; + bool first = true, has_embedded_flexible_array, has_flexible_array; /* * We may not yet have looked for holes and paddings in this member's * struct type. @@ -1525,9 +1525,10 @@ static size_t class__fprintf_member_type_holes(struct class *class, const struct bit_padding = class->bit_padding; nr_holes = class->nr_holes; nr_bit_holes = class->nr_bit_holes; + has_flexible_array = class__has_flexible_array(class, cu); has_embedded_flexible_array = class__has_embedded_flexible_array(class, cu); - if (!padding && !bit_padding && !nr_holes && !nr_bit_holes && !has_embedded_flexible_array) + if (!padding && !bit_padding && !nr_holes && !nr_bit_holes && !has_flexible_array && !has_embedded_flexible_array) return 0; if (!(*newline)++) { @@ -1537,11 +1538,16 @@ static size_t class__fprintf_member_type_holes(struct class *class, const struct printed += fprintf(fp, "\n%.*s/* XXX last struct has", conf->indent, tabs); - if (has_embedded_flexible_array) { + if (has_flexible_array) { printed += fprintf(fp, " a flexible array"); first = false; } + if (has_embedded_flexible_array) { + printed += fprintf(fp, "%s embedded flexible array(s)", first ? "" : ","); + first = false; + } + if (padding) { ++holes->nr_paddings; holes->sum_paddings += padding; -- 2.46.0