Re: [PATCH v6 04/19] fsck: Offer a function to demote fsck errors to warnings
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jun 22, 2015, 15:24 UTC
- Message-ID
- <d58343ff03fbc41b8d1346419ce2c389@www.dscho.org>
- In-Reply-To
- <xmqqzj3v7b58.fsf@gitster.dls.corp.google.com>
Hi Junio,
On 2015-06-19 21:26, Junio C Hamano wrote:
Show 29 quoted lines
> Johannes Schindelin <johannes.schindelin@gmx.de> writes:
>
>> +static inline int substrcmp(const char *string, int len, const char *match)
>> +{
>> + int match_len = strlen(match);
>> + if (match_len != len)
>> + return -1;
>> + return memcmp(string, match, len);
>> +}
>
> What this does looks suspiciously like starts_with(), but its name
> "substrcmp()" does not give any hint that this is about the beginnig
> part of "string"; if anything, it gives a wrong hint that it may be
> any substring. prefixcmp() might be a better name but that was the
> old name for !starts_with() so we cannot use it here. It is a
> mouthful, but starts_with_counted() may be.
>
> But the whole thing may be moot.
>
> If we take the "why not upcase the end-user string upfront"
> suggestion from the previous review, fsck_set_msg_types() would have
> an upcased copy of the end-user string that it can muck with; it can
> turn "badfoo=error,poorbar=..." into "BADFOO=error,POORBAR=..."
> that is stored in its own writable memory (possibly a strbuf), and
> at that point it can afford to NUL-terminate BADFOO=error after
> finding where one specification ends with strcspn() before calling
> fsck_set_msg_type(), which in turn calls parse_msg_type().
>
> So all parse_msg_type() needs to do is just !strcmp().Turns out that the diffstat says it saves 10 lines. So I changed it according to your suggestion. Part of v7.
Ciao, Dscho