rfuchs left a comment (kamailio/kamailio#4781)

> Designated field initialisation on declaration (introduced in C99) should 
> ensure that the other fields (not initialised explicitly by name) are 
> initialised by the compiler, but that might not be as a block of zeros. I 
> haven't checked if all compilers comply and from what version.

To my knowledge, this behaviour (zero-initialise of any struct members that 
aren't listed) is part of the standard and therefore required. Any compiler not 
doing it would be broken.

> I was calling for other developers to express their opinion before deciding 
> to merge. I see it more like a cosmetic change (that can be applied in many 
> other parts of code), rather than a real necessity.

Theoretically, initialising the struct with a compound literal would be faster 
than doing a memset and then overwriting the zeroed members, but in practice a 
good compiler optimises this anyway, and the resulting instructions are very 
similar or even identical:  https://godbolt.org/z/od8rzMvcK

Personally I prefer direct initialisation with a compound literal as I find it 
easier to read, but yeah, this is really cosmetic.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/4781#issuecomment-4855346469
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/pull/4781/[email protected]>
_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to