From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 91CB21F4B4 for ; Fri, 9 Apr 2021 18:10:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234437AbhDISKU (ORCPT ); Fri, 9 Apr 2021 14:10:20 -0400 Received: from cloud.peff.net ([104.130.231.41]:46564 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233332AbhDISKT (ORCPT ); Fri, 9 Apr 2021 14:10:19 -0400 Received: (qmail 669 invoked by uid 109); 9 Apr 2021 18:10:06 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 09 Apr 2021 18:10:06 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 14662 invoked by uid 111); 9 Apr 2021 18:10:06 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Fri, 09 Apr 2021 14:10:06 -0400 Authentication-Results: peff.net; auth=none Date: Fri, 9 Apr 2021 14:10:05 -0400 From: Jeff King To: =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Cc: git@vger.kernel.org, Junio C Hamano , Johannes Schindelin , Taylor Blau , Elijah Newren Subject: Re: [PATCH 1/6] object.c: stop supporting len == -1 in type_from_string_gently() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, Apr 09, 2021 at 02:06:51PM -0400, Jeff King wrote: > On Fri, Apr 09, 2021 at 10:32:49AM +0200, Ævar Arnfjörð Bjarmason wrote: > > > 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). Actually, seeing patch 2, which changes the signature, mostly deals with this. The compiler would complain about any existing calls because of dropping the "gentle" parameter (it is up to the human to realize that they need to make sure we are not passing a negative len, but hopefully they would look at the other commits at that point). -Peff