Re: [PATCH v3 1/7] git docs: split "User-facing file formats" off from "Guides"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 12 2022, Ævar Arnfjörð Bjarmason wrote:

> @@ -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.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux