svn commit: r277203 - in head/sys: kern sys

Robert N. M. Watson rwatson at FreeBSD.org
Fri Jan 30 19:40:35 UTC 2015


> On 15 Jan 2015, at 12:35, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> 
> On Wed, Jan 14, 2015 at 11:44:00PM +0000, Robert Watson wrote:
>>  - As we anticipate embedding mbufs headers within variable-size regions of
>>    memory in the future, change the definitions of byte arrays embedded in
>>    mbufs to be of size [0] rather than [MLEN] and [MHLEN].
> 
> This is not valid C. You may be able to use flexible array members ([])
> instead.

Life is not that simple -- see the Phabricator review discussion which considers this point in detail. The short version is: using [] for the last entry in a union within a structure is explicitly disallowed in the C spec, actually works fine with [0] in gcc + extensions, which are a feature used in the kernel already. If in doubt, try replacing [0] with [] and recompiling, it's an instructive and morally improving process. We will want to feed this back to the C standardisation folk at some point.

Robert


More information about the svn-src-all mailing list