Re: [PATCH v3 08/27] revisions API users: add "goto cleanup" for "rev_info" early exit
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 25, 2022, 20:30 UTC
- Message-ID
- <xmqqtubl93n3.fsf@gitster.g>
- In-Reply-To
- <patch-v3-08.27-f8a9443fe6f-20220325T171340Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> 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.