fprintf: Print zero sized flat arrays as [], not [0]

To match the case when we really have just one dimension, so the
--flat-arrays should show for zero sized arrays, [], not [0]:

Noticed with btfdiff.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2019-04-10 18:25:37 -03:00
parent f909f13dd7
commit ea583dac52
1 changed files with 6 additions and 2 deletions

View File

@ -232,8 +232,12 @@ static size_t array_type__fprintf(const struct tag *tag,
flat_dimensions = 1;
printed += fprintf(fp, " __attribute__ ((__vector_size__ (%llu)))",
flat_dimensions * tag__size(type, cu));
} else if (conf->flat_arrays)
printed += fprintf(fp, "[%llu]", flat_dimensions);
} else if (conf->flat_arrays) {
if (flat_dimensions != 0)
printed += fprintf(fp, "[%llu]", flat_dimensions);
else
printed += fprintf(fp, "[]");
}
return printed;
}