On 2 January 2015 at 04:07, David Chisnall <thera...@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.
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to