Message ID | 20240104204614.1426027-2-pvorel@suse.cz |
---|---|
State | Changes Requested |
Headers | show |
Series | metadata: improvements | expand |
Hi all, > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > metadata/metaparse.c | 3 +++ > 1 file changed, 3 insertions(+) > diff --git a/metadata/metaparse.c b/metadata/metaparse.c > index 2384c73c8..fe6d68911 100644 > --- a/metadata/metaparse.c > +++ b/metadata/metaparse.c > @@ -862,6 +862,9 @@ int main(int argc, char *argv[]) > return 1; > } > + if (verbose) > + fprintf(stderr, "\n=== %s ===\n", argv[optind]); > + This introduces warning: $ make metaparse In file included from metaparse.c:17: In function ‘data_node_string’, inlined from ‘main’ at metaparse.c:894:6: data_storage.h:84:20: warning: array subscript ‘struct data_node[0]’ is partly outside array bounds of ‘unsigned char[6]’ [-Warray-bounds=] 84 | node->type = DATA_STRING; | ~~~~~~~~~~~^~~~~~~~~~~~~ data_storage.h:79:34: note: object of size 6 allocated by ‘malloc’ 79 | struct data_node *node = malloc(size); | ^~~~~~~~~~~~ HOSTCC metadata/metaparse What am I missing? > res = parse_file(argv[optind]); > if (!res) > return 0;
Hi! > This introduces warning: > > $ make metaparse > In file included from metaparse.c:17: > In function ‘data_node_string’, > inlined from ‘main’ at metaparse.c:894:6: > data_storage.h:84:20: warning: array subscript ‘struct data_node[0]’ is partly outside array bounds of ‘unsigned char[6]’ [-Warray-bounds=] > 84 | node->type = DATA_STRING; > | ~~~~~~~~~~~^~~~~~~~~~~~~ > data_storage.h:79:34: note: object of size 6 allocated by ‘malloc’ > 79 | struct data_node *node = malloc(size); > | ^~~~~~~~~~~~ > HOSTCC metadata/metaparse > > What am I missing? This looks like the compiler is confused by the union and flexible array and static analysis produces gibberish. The very fact that this is triggered by addition of unrelated piece of code supports that hypotesis as well.
Hi!
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> Hi! > > This introduces warning: > > $ make metaparse > > In file included from metaparse.c:17: > > In function ‘data_node_string’, > > inlined from ‘main’ at metaparse.c:894:6: > > data_storage.h:84:20: warning: array subscript ‘struct data_node[0]’ is partly outside array bounds of ‘unsigned char[6]’ [-Warray-bounds=] > > 84 | node->type = DATA_STRING; > > | ~~~~~~~~~~~^~~~~~~~~~~~~ > > data_storage.h:79:34: note: object of size 6 allocated by ‘malloc’ > > 79 | struct data_node *node = malloc(size); > > | ^~~~~~~~~~~~ > > HOSTCC metadata/metaparse > > What am I missing? > This looks like the compiler is confused by the union and flexible array > and static analysis produces gibberish. The very fact that this is > triggered by addition of unrelated piece of code supports that hypotesis > as well. Thanks for info. So really false positive? Therefore we have nothing to improve and we should report to gcc? Kind regards, Petr
diff --git a/metadata/metaparse.c b/metadata/metaparse.c index 2384c73c8..fe6d68911 100644 --- a/metadata/metaparse.c +++ b/metadata/metaparse.c @@ -862,6 +862,9 @@ int main(int argc, char *argv[]) return 1; } + if (verbose) + fprintf(stderr, "\n=== %s ===\n", argv[optind]); + res = parse_file(argv[optind]); if (!res) return 0;
Signed-off-by: Petr Vorel <pvorel@suse.cz> --- metadata/metaparse.c | 3 +++ 1 file changed, 3 insertions(+)