Re: [PATCH v2 2/8] config.c: don't assign to "cf_global" directly
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 16, 2023, 21:31 UTC
- Message-ID
- <xmqq4jqkjsd2.fsf@gitster.g>
- In-Reply-To
- <20230316211821.313426-1-jonathantanmy@google.com>
Jonathan Tan <jonathantanmy@google.com> writes:
Show 8 quoted lines
> "Glen Choo via GitGitGadget" <gitgitgadget@gmail.com> writes:
>> +static inline void config_reader_push_source(struct config_source *top)
>> +{
>> + if (cf_global)
>> + top->prev = cf_global;
>
> Don't we want to set prev unconditionally here (i.e. set it to NULL if
> cf_global was NULL)?Good eyes. You are absolutely right. Thanks.
Show 17 quoted lines
>
>> + cf_global = top;
>> +}
>> +
>> +static inline struct config_source *config_reader_pop_source()
>> +{
>> + struct config_source *ret;
>> + if (!cf_global)
>> + BUG("tried to pop config source, but we weren't reading config");
>> + ret = cf_global;
>> + cf_global = cf_global->prev;
>> + return ret;
>> +}
>
> ...since we use it unconditionally here.
>
> The rest looks good.