From: Han-Wen Nienhuys Date: Tue, 11 Jan 2022 19:31:47 GMT Subject: Re: [PATCH 3/3] reftable tests: avoid "int" overflow, use "uint64_t" Message-ID: In-Reply-To: On Tue, Jan 11, 2022 at 8:28 PM Taylor Blau wrote: > > On Tue, Jan 11, 2022 at 05:40:23PM +0100, Ævar Arnfjörð Bjarmason wrote: > > diff --git a/reftable/merged_test.c b/reftable/merged_test.c > > index 24461e8a802..b87ff495dfd 100644 > > --- a/reftable/merged_test.c > > +++ b/reftable/merged_test.c > > @@ -24,8 +24,8 @@ license that can be found in the LICENSE file or at > > static void write_test_table(struct strbuf *buf, > > struct reftable_ref_record refs[], int n) > > { > > - int min = 0xffffffff; > > - int max = 0; > > + uint64_t min = 0xffffffff; > > + uint64_t max = 0; > > Han-Wen: it looks like the loop below the context here is to set the > min/max of update_index over all of the ref records? correct. > But perhaps not so from a width perspective, if sizeof(int) != 8 (though > I suspect in practice that we are unlikely to have enough possible > values of update_index for that to matter). correct. > In any case, you're only setting the lower half of `min` high. Maybe: > > uint64_t min = ~0ul; yeah, that works. -- Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado