Re:The trouble with struct sockaddr's fake flexible array
by dwattttt on Friday November 29, 2024 @06:14AM
(#42273020)
I imagine the problem they're trying to address is ensuring that everyone _does_ only use correctly cast pointers; as defined, it's legal to use that 14 char array, it's just that it's never what you're meant to do.
Re:The trouble with struct sockaddr's fake flexible array
by kazinator on Friday November 29, 2024 @02:54PM
(#42276579)
In my opinion, the array should be marked obsolescent, and removed (not necessarily physically, but the name gone from the member namespace). The 14 bytes is not enough for it to be define storage for all types, which is why sockaddr_storage is there. It cannot meaningfully access anything. Implementations could rename it to some __sa_data or whatever name so that the size of the structure doesn't change, if that is important to them.
For defining or allocating an object that can hold any address, sa_storage should be used, mentioned in the article.