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=-2.1 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no 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 B11561F406 for ; Wed, 11 Oct 2023 23:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233831AbjJKXJa (ORCPT ); Wed, 11 Oct 2023 19:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbjJKXJ3 (ORCPT ); Wed, 11 Oct 2023 19:09:29 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B64B59D for ; Wed, 11 Oct 2023 16:09:28 -0700 (PDT) Received: (qmail 20502 invoked by uid 109); 11 Oct 2023 23:09:28 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Wed, 11 Oct 2023 23:09:28 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 11212 invoked by uid 111); 11 Oct 2023 23:09:30 -0000 Received: from coredump.intra.peff.net (HELO coredump.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Wed, 11 Oct 2023 19:09:30 -0400 Authentication-Results: peff.net; auth=none Date: Wed, 11 Oct 2023 19:09:27 -0400 From: Jeff King To: Taylor Blau Cc: git@vger.kernel.org Subject: Re: [PATCH 08/20] midx: enforce chunk alignment on reading Message-ID: <20231011230927.GJ518221@coredump.intra.peff.net> References: <20231009205544.GA3281950@coredump.intra.peff.net> <20231009210523.GH3282181@coredump.intra.peff.net> 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 Wed, Oct 11, 2023 at 11:01:09AM -0400, Taylor Blau wrote: > On Mon, Oct 09, 2023 at 05:05:23PM -0400, Jeff King wrote: > > @@ -120,6 +121,11 @@ int read_table_of_contents(struct chunkfile *cf, > > error(_("terminating chunk id appears earlier than expected")); > > return 1; > > } > > + if (chunk_offset % expected_alignment != 0) { > > Oops, I missed this in my first read. I'm definitely nit-picking here, > but this should probably be: > > if (chunk_offset % expected_alignment) > > without the trailing "!= 0". > > I don't have a strong preference here, since we are doing a comparison > of an arithmetic operation against an (un-)expected value. But I think > the CodingGuidelines would technically call this out of style... I suppose so, but somehow I consider the subtlety of "%" to merit the more explicit comparison (versus something like "if (foo)"). Grepping for "if (.* %)' seems to show some of both. -Peff