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.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS,URIBL_SBL, URIBL_SBL_A 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 AFA611F852 for ; Wed, 12 Jan 2022 19:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356366AbiALTCO (ORCPT ); Wed, 12 Jan 2022 14:02:14 -0500 Received: from pb-smtp21.pobox.com ([173.228.157.53]:65224 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344097AbiALTCK (ORCPT ); Wed, 12 Jan 2022 14:02:10 -0500 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id B43A616B953; Wed, 12 Jan 2022 14:02:09 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=bSFA+ppkkcuSF3eosV/5ygIWX09Z7wxJhsCHis f1mzM=; b=DHVmCEKemxaaV1jPs+luNyZ9+g7s+C+EtyNippeKuKPc6vDgbBLjA1 raYfuw4axzExZl7sDiO3ZMq5ap0RrMf98sS7lWJwCZQYa/vysXdtRbD8AGinIsiy 7LhKqvrk8W4JxPEiCSLF+0gBHkSt5FnX7ckbTEFZ3Y+WVjNcRJ1/I= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id AAE5F16B951; Wed, 12 Jan 2022 14:02:09 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [104.133.2.91]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 247B616B94F; Wed, 12 Jan 2022 14:02:07 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: Johannes Sixt Cc: Taylor Blau , Han-Wen Nienhuys , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , git@vger.kernel.org, Johannes Schindelin Subject: Re: [PATCH 3/3] reftable tests: avoid "int" overflow, use "uint64_t" References: <45baffd7-c9f3-cc52-47b4-ea0fee0182a8@kdbg.org> Date: Wed, 12 Jan 2022 11:02:05 -0800 In-Reply-To: (Johannes Sixt's message of "Tue, 11 Jan 2022 21:21:11 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 23298A56-73DA-11EC-A3BC-CBA7845BAAA9-77302942!pb-smtp21.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Johannes Sixt writes: > Am 11.01.22 um 21:18 schrieb Taylor Blau: >> On Tue, Jan 11, 2022 at 09:08:46PM +0100, Johannes Sixt wrote: >>> Am 11.01.22 um 20:41 schrieb Taylor Blau: >>>> On Tue, Jan 11, 2022 at 08:31:47PM +0100, Han-Wen Nienhuys wrote: >>>>> On Tue, Jan 11, 2022 at 8:28 PM Taylor Blau wrote: >>>>>> In any case, you're only setting the lower half of `min` high. Maybe: >>>>>> >>>>>> uint64_t min = ~0ul; >>>>> >>>>> yeah, that works. >>>> >>>> I'm pretty sure this is OK on 32-bit systems, too, but confirmation from >>>> somebody more confident than I in this area would be welcome :). >>> >>> It does not work on Windows: unsigned long is 32 bits wide. You have to >>> make it >>> >>> uint64_t min = ~(uint64_t)0; >> >> Perfect; this is exactly what I was looking for. Thanks! That sounds perfect. > Actually, on second thought, UINT64_MAX would be even better. I wouldn't introduce use of UINT64_MAX, which "git grep" does not produce any hits for. Unless it is very early in a development cycle, that is, in which case we have enough time to help platforms that are not quite POSIX.