Re: [LTP] [PATCH 1/9] metaparse: Print parsing file on verbose

Cyril Hrubis
2024-02-23T12:14:20Z

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.

--
Cyril Hrubis
chrubis@suse.cz