Thread (1 message) 1 message, 1 author, 2020-10-12

Re: [PATCH v2 1/3] merge-base, xdiff: zero out xpparam_t structures

From: Junio C Hamano <hidden>
Date: 2020-10-12 17:09:18

Johannes Schindelin [off-list ref] writes:
quoted
 	xpparam_t xpparam;
+
+	memset(&xpparam, 0, sizeof(xpparam));
A slightly more elegant way to do this would be

	xpparam_t xpparam = { 0l };

Or even

	xpparam_t xpparam = XPPARAM_T_INIT;

with

	#define XPPARAM_T_INIT { 0l, NULL, 0 }

in `xdiff/xdiff.h`.
Let's not suggest any of the above.

I think we had a recent thread [*1*] on which we agreed that "{ 0 }"
is the way to spell "a naturally zero" initialization like this one,
if we were to spell it out.

TBH, I'd say that memset() is also OK as-is in this codebase as an
established way (git grep 'memset([^,]*, 0, sizeof' gives too many
hits).

Thanks.


[Reference]

*1* https://lore.kernel.org/git/xmqq4knca7c6.fsf@gitster.c.googlers.com/ (local)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help