Re: [PATCH 1/6] object.c: stop supporting len == -1 in type_from_string_gently()
- From
Jeff King <peff@peff.net>
- Date
- Apr 9, 2021, 18:06 UTC
- Message-ID
- <YHCXux5KJmwX3OSv@coredump.intra.peff.net>
- In-Reply-To
- <patch-1.6-820f3aed21-20210409T082935Z-avarab@gmail.com>
On Fri, Apr 09, 2021 at 10:32:49AM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 11 quoted lines
> diff --git a/object.c b/object.c
> index 7fdca3ed1e..88de01e5ac 100644
> --- a/object.c
> +++ b/object.c
> @@ -39,9 +39,6 @@ int type_from_string_gently(const char *str, ssize_t len, int gentle)
> {
> int i;
>
> - if (len < 0)
> - len = strlen(str);
> -The "ssize_t len" in the parameters could become a size_t now, right?
Not strictly necessary, but in theory it may help static analysis catch a caller who mistakenly tries to pass -1 (though in practice I suspect it does not help that much, because any of gcc's sign-conversion warnings generate far too much noise to be useful with our current codebase).
-Peff