Closed dridi closed 5 years ago
Well, the packing is intentional, but can probably be removed. It might save some space, but that's quite minor.
As long as it's read the same way as it's written, it shouldn't really matter if it's unpacked (and I guess therefore might differ between compilers). kcov reads and writes this data all by itself, so I don't see any disadvantages with removing it.
Thanks!
Care to submit a pull request?
Sure thing, I submitted #312.
Great, thanks a lot!
I'm building kcov with GCC 9.2.1 and get the following warnings:
They appear because
struct line_entry
is packed and loses alignment guarantees for the flex-arrayentries
. The warning goes away with a simple change:However I'm not sure how safe it is to make this change since the result is serialized. Could the structure be written as-is today and later be (mis)read by a patched kcov after an upgrade?
An alternative would be keep the packed structure and allocate a temporary line entry on the stack, and
memcpy
its contents for each entry: we get both a packed structure and alignment guarantees. However this doesn't work ifentries
are manipulated in-memory and not only to be serialized on disk (which I didn't verify).This is generally not a problem on x86 hardware but could be on other architectures.