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-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 DAD701F4B4 for ; Tue, 12 Jan 2021 08:55:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732597AbhALIyq (ORCPT ); Tue, 12 Jan 2021 03:54:46 -0500 Received: from cloud.peff.net ([104.130.231.41]:53076 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728080AbhALIyq (ORCPT ); Tue, 12 Jan 2021 03:54:46 -0500 Received: (qmail 6220 invoked by uid 109); 12 Jan 2021 08:54:06 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 12 Jan 2021 08:54:05 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 10916 invoked by uid 111); 12 Jan 2021 08:54:08 -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; Tue, 12 Jan 2021 03:54:08 -0500 Authentication-Results: peff.net; auth=none Date: Tue, 12 Jan 2021 03:54:05 -0500 From: Jeff King To: Taylor Blau Cc: Derrick Stolee , git@vger.kernel.org, jrnieder@gmail.com Subject: Re: [PATCH 05/20] check_object(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Jan 11, 2021 at 11:15:49AM -0500, Taylor Blau wrote: > On Mon, Jan 11, 2021 at 06:43:23AM -0500, Derrick Stolee wrote: > > > @@ -1813,11 +1813,11 @@ static void check_object(struct object_entry *entry, uint32_t object_index) > > > goto give_up; > > > } > > > if (reuse_delta && !entry->preferred_base) { > > > - struct revindex_entry *revidx; > > > - revidx = find_pack_revindex(p, ofs); > > > - if (!revidx) > > > + uint32_t pos; > > > + if (offset_to_pack_pos(p, ofs, &pos) < 0) > > > > The current implementation does not return a positive value. Only > > -1 on error and 0 on success. Is this "< 0" doing anything important? > > Seems like it would be easiest to do > > > > if (offset_to_pack_pos(p, ofs, &pos)) > > > > [snip] > > Either would work, of course. I tend to find the '< 0' form easier to > read, but I may be in the minority there. For me, the negative return > value makes clear that the function encountered an error. I'll throw in my opinion that "< 0" to me much more clearly signals "did an error occur". And that same form can be used consistently with functions which _do_ have a positive return value on success, too. So I prefer it for readability. -Peff