Re: [RFC PATCH 1/1] hideTimezone: add a user.hideTimezone config
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 3, 2020, 04:57 UTC
- Message-ID
- <xmqqzh537vp5.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20201002223212.93266-1-shengfa@google.com>
Shengfa Lin <shengfa@google.com> writes:
Show 13 quoted lines
>>>>> + git_config(git_default_config, NULL); >>>> >>>> Declaration after statement is not tolerated in this codebase. >>> >>> If I use the DEVELOPER=1 flag in config.mak and call make again, would the compiler >>> catches this as an error? >> >> Yes, DEVELOPER_CFLAGS includes -Wdeclaration-after-statement. > > Got the error from int hide_timezone = 0; but not > git_config(git_default_config, NULL);. > ... >>>>> + int hide_timezone = 0;
That is exactly expected.
The problematic sequence was
... s.colopts = 0;
git_config(git_default_config, NULL); int hide_timezone = 0;
The assignment of 0 to s.colopts, which existed before your patch, was already a statement. So is a new call to git_config() function you added. As the existing "s.colopts = 0" were in a place where a statement can legally appear, the place you added git_config() call is also where a statement can legally appear. There is nothing for the compiler to complain about.
The declaration of hide_timezone added _after_ that statement is a different story. Because the -Wdeclaration-after-statement is about starting a function (or "a block" in general) with all the necessary declarations before we write a single statement, and also forbidding us from adding other declarations after we write a statement. Since there are bunch of statements in the same block already, including the assignment to s.colopts and a call to git_config(), we cannot add a declaration after that.
Thanks.