Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32861 )
Change subject: device_tree: Switch allocations to xzalloc() ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/#/c/32861/5/src/lib/device_tree.c File src/lib/device_tree.c:
https://review.coreboot.org/#/c/32861/5/src/lib/device_tree.c@171 PS5, Line 171: xzalloc
xmalloc?
It's just a safety precaution to do this everywhere, I think (copied this from depthcharge). Otherwise you always have to carefully check whether you're *really* initializing every single member, and if anyone ever adds new members then they might forget to change code like this. It's easy to overlook things... for example, if I just changed this to xmalloc() without adding more code, the list_node pointers in the struct wouldn't get initialized to NULL.
(FWIW due to the way the heap in coreboot is currently implemented, allocations are always guaranteed to be zero-initialized anyway. We could optimize xzalloc() to just be a synonym for xmalloc() in coreboot. Not sure if it's worth the risk of someone changing the heap implementation later and not noticing, though. memset() on the L1 cache is cheap.)