Re: [PATCH v3 1/7] git docs: split "User-facing file formats" off from "Guides"
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 13, 2022, 01:09 UTC
- Message-ID
- <220713.86r12p4xwo.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <patch-v3-1.7-929d9192828-20220712T195419Z-avarab@gmail.com>
On Tue, Jul 12 2022, Ævar Arnfjörð Bjarmason wrote:
Show 14 quoted lines
> @@ -47,8 +48,12 @@ static const char *drop_prefix(const char *name, uint32_t category)
>
> if (skip_prefix(name, "git-", &new_name))
> return new_name;
> - if (category == CAT_guide && skip_prefix(name, "git", &new_name))
> + switch (category) {
> + case CAT_guide:
> + case CAT_userformats:
> + skip_prefix(name, "git", &new_name);
> return new_name;
> + }
> return name;
>
> }I noticed after submission that -fanalyzer complaints about this, since according to it (and probably also coverity etc.) we could return a NULL "new_name" there, i.e. if the "skip_prefix" doesn't succeed.
I'll guard this in the inevitable re-roll, but FWIW this isn't a logic error now, it's just that the compiler can't see that.
All of these categories (and the one added in 2/7) have strings that start with "git", so we'll never have a NULL "new_name" here, we always skip that prefix.
Of course that depends on the relevant categories in command-list.txt having git* names, but we know that's the case, and that'll probably never change. So I'll just have this BUG() out if the constraint is violated.