Re: [PATCH v2 1/1] gpg-interface: add minTrustLevel as a configuration option
- From
Hans Jerry Illikainen <hji@dyntopia.com>
- Date
- Dec 27, 2019, 13:46 UTC
- Message-ID
- <87r20pkhir.hji@dyntopia.com>
- In-Reply-To
- <xmqqblrx5yxu.fsf@gitster-ct.c.googlers.com>
On Tue, Dec 24 2019, Junio C Hamano wrote:
Show 24 quoted lines
> Hans Jerry Illikainen <hji@dyntopia.com> writes:
>
>> + /* Do we have trust level? */
>> + if (sigcheck_gpg_status[i].flags & GPG_STATUS_TRUST_LEVEL) {
>> + /*
>> + * GPG v1 and v2 differs in how the
>> + * TRUST_ lines are written. Some
>> + * trust lines contain no additional
>> + * space-separated information for v1.
>> + */
>> + next = strchr(line, ' ');
>> + if (!next)
>> + next = strchrnul(line, '\n');
>> + trust = xmemdupz(line, next - line);
>
> I wonder if telling strcspn() to stop at either SP or LF is more in
> line with the existing codebase [*1*] and/or more readable. It
> would make this part to:
>
> size_t trust_size = strcspn(line, " \n");
> trust = xmemdupz(line, trust_size);
>
> without the need to use or update the 'next' variable, if I am not
> mistaken?I agree; fixed in v3.
Show 11 quoted lines
> By the way, while we are looking at this patch, I notice that, > throughout the function, the use of variable 'next' feels rather > misleading, at least to me. > > [...] > > I wonder if the code becomes less misleading if we either (1) > renamed 'next' to a name that hints more strongly that it is not the > 'next' line but the end of the current token we are interested in, > or (2) get rid of the pointer and instead counted size of the > current token we are interested in, or perhaps both?
Yeah the name 'next' does seem a bit counter-intuitive when used in relation to 'line'. Looking through the function it seems that both (1) and (2) would work.
> This is not the fault of this patch, but I just mention it before I > forget. > > Thanks.
Thanks for the review!
-- hji