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 6E5AB1F5AE for ; Wed, 21 Jul 2021 11:09:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237954AbhGUJVw (ORCPT ); Wed, 21 Jul 2021 05:21:52 -0400 Received: from cloud.peff.net ([104.130.231.41]:52896 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237061AbhGUJEv (ORCPT ); Wed, 21 Jul 2021 05:04:51 -0400 Received: (qmail 1721 invoked by uid 109); 21 Jul 2021 09:44:54 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 21 Jul 2021 09:44:54 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 2668 invoked by uid 111); 21 Jul 2021 09:45:14 -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; Wed, 21 Jul 2021 05:45:14 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 21 Jul 2021 05:45:12 -0400 From: Jeff King To: Taylor Blau Cc: git@vger.kernel.org, dstolee@microsoft.com, gitster@pobox.com, jonathantanmy@google.com Subject: Re: [PATCH v2 01/24] pack-bitmap.c: harden 'test_bitmap_walk()' to check type bitmaps 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, Jun 21, 2021 at 06:24:59PM -0400, Taylor Blau wrote: > The special `--test-bitmap` mode of `git rev-list` is used to compare > the result of an object traversal with a bitmap to check its integrity. > This mode does not, however, assert that the types of reachable objects > are stored correctly. > > Harden this mode by teaching it to also check that each time an object's > bit is marked, the corresponding bit should be set in exactly one of the > type bitmaps (whose type matches the object's true type). Yep, makes sense, and the patch looks good. > +{ > + enum object_type bitmap_type = OBJ_NONE; > [...] > + > + if (!bitmap_type) > + die("object %s not found in type bitmaps", > + oid_to_hex(&obj->oid)); I think the suggestion to do: if (bitmap_type == OBJ_NONE) is reasonable here, as it assumes less about the enum. I do think OBJ_BAD and OBJ_NONE were chosen with these kind of numeric comparisons in mind, but there is no reason to rely on them in places we don't need to. -Peff