On 2 January 2015 at 04:07, David Chisnall <theraven_at_freebsd.org> wrote: > > The correct solution is to declare the array to have 0 elements (although this will break C++ code). A zero-length array at the end of a structure is specifically defined by the C standard (since C99) to be a variable-length array. A length-one array was used in C89 prior to this for this purpose. Using a 1-element array in C is undefined behaviour. > > Note that this change will also require fixing code that allocates it to allocate space for n elements not n-1. I was thinking of making that change, but the driver was not particularly straightforward. In addition to your point about allocation I noticed that it used sizeof() the union containing these variable-length-array structs. I wouldn't want to try to fix it without hardware to test.Received on Fri Jan 02 2015 - 13:42:42 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:54 UTC