Subject: Re: [PATCH v3 08/27] revisions API users: add "goto cleanup" for "rev_info" early exit

From: Junio C Hamano <[email-masked]>
Date: Fri, 25 Mar 2022 13:30:08 -0700

Ævar Arnfjörð Bjarmason <[email-masked]> writes:

> It would be a lot cleaner to be able to initialize "struct rev_info"
> with "{ 0 }" here, or if a "REV_INFO_INIT" existed, we'll hopefully
> get around to making the initialization easier in the future (now it
> can't be done via a macro).

If "struct rev_info" can be initialized with "{ 0 }" here, i.e.

-	struct rev_info rev;
+	struct rev_info rev = { 0 };

to give us a valid solution, why wouldn't you be able to do

+#define REV_INFO_INIT { 0 }

elsewhere in a common *.h file, and then

-	struct rev_info rev;
+	struct rev_info rev = REV_INFO_INIT;

to make the fact that "rev" is initialized (and ready to be handed
to the releaser) even more explicit?  It's like arguing against
fixing a code like this:

	struct char *pointer;
	...
	if (condition)
		pointer = malloc(...);
	...
        /* pointer leaks */
 
by initializing

	struct char *pointer = NULL;
	...
	if (condition)
		pointer = malloc(...);
	...
        free(pointer);

because for some reason you are against the macro NULL but you are
willing to spell it out as "0" (without double-quotes)?

Puzzled.