From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 4CB791F428 for ; Tue, 21 Mar 2023 17:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjCURiU (ORCPT ); Tue, 21 Mar 2023 13:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbjCURiS (ORCPT ); Tue, 21 Mar 2023 13:38:18 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03D012594 for ; Tue, 21 Mar 2023 10:37:17 -0700 (PDT) Received: (qmail 27746 invoked by uid 109); 21 Mar 2023 17:35:57 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 21 Mar 2023 17:35:57 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 2330 invoked by uid 111); 21 Mar 2023 17:35:56 -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, 21 Mar 2023 13:35:56 -0400 Authentication-Results: peff.net; auth=none Date: Tue, 21 Mar 2023 13:35:56 -0400 From: Jeff King To: Taylor Blau Cc: git@vger.kernel.org, Junio C Hamano , Derrick Stolee , Abhradeep Chakraborty Subject: Re: [PATCH 1/6] pack-bitmap.c: hide bitmap internals in `read_u8()` Message-ID: <20230321173556.GD3119834@coredump.intra.peff.net> References: <8c70c94a3f5f0463041dbaaa542fd69bd159428b.1679342296.git.me@ttaylorr.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <8c70c94a3f5f0463041dbaaa542fd69bd159428b.1679342296.git.me@ttaylorr.com> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Mon, Mar 20, 2023 at 04:02:40PM -0400, Taylor Blau wrote: > So b5007211b6 got rid of the above convention and replaced it by reading > individual fields of that structure with a `read_u8()` helper that reads > from the region of memory pointed to by `->map`, and updates the > `->map_pos` pointer accordingly. > > But this forces callers to be intimately aware of `bitmap_git->map` and > `bitmap_git->map_pos`. Instead, teach `read_u8()` to take a `struct > bitmap_index *` directly, and avoid having callers deal with the > internals themselves. OK. I always felt like this read_u8() and read_be32() were trying to match get_be32(), etc, just with an auto-incrementing "pos" pointer. And this patch makes them a lot less generic. But that is probably OK. They are static-local to the bitmap file, and we have not found another caller who wanted them in the intervening years. Arguably they could be given more descriptive names, like read_bitmap_u8() or something, but again, being static-local to the file, the generic names are fine. -Peff