From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by sourceware.org (Postfix) with ESMTPS id 3F4673858D32 for ; Mon, 13 Mar 2023 12:40:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3F4673858D32 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oo1-xc33.google.com with SMTP id h18-20020a4abb92000000b00525397f569fso1799826oop.3 for ; Mon, 13 Mar 2023 05:40:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678711251; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bugvwYSgCAPqCE7jyiQ1nkhrXqe54ZSED3lsgMxhQt0=; b=ReSN+6yW71N+2fxmO1khCzYrdRE87Td+O+yLGSs50AwrkuJEEsyJZTWHd0rBbBnuyj 6pKjZJwb4J4sUEnQ+GBRJcGpEbLQG2/yLBhnl83sP9isteXYMDPV1chh/S8m0G8kBzi8 mwjKsOgHbpwsvSZe1+R6dYMZMoO2XCL3Lpwxmt/9JpVn4ge9KpFOFrVHnw9LbyNIqlp4 WXuxEizoVGbE8Ocw3udEkNgpz1vbRWLiY2ULAA4qaB5kHEyFKWH7uyhkJaJohqD/P/Tr mUhVYChyvq8RBXCHB0OG8yrBMBwDQmGLldEUdid08onrY/m0EzGqdD2G4cYSnAV+TTu8 mxog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678711251; h=content-transfer-encoding:in-reply-to:organization:from:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bugvwYSgCAPqCE7jyiQ1nkhrXqe54ZSED3lsgMxhQt0=; b=Hq8QHmgnx3vat6OhViVmCCFW1UVedplQsgwDDoETeyKmW+k7bpE/rAkGXpiwaJ76Uo bTrJ1Sf71PLOuzc0yMEfHPuP6m/wZTOkybeRfTqt27h248vhUub/DVQFjhQyxmh4BZ7G heQMXxJa8TsJaVwBQgjjDlzwLqQVKpyYKmdFbmE/k24ugdU7fdqT+d4BCecAA0V8TLx3 FJ/1Qcsio+X50RLKhFHs29jbv0JeDjCIjTxRepN7DoLnfj1uCyIZfEDegMKn7zRUCjIw YLF/ka1e2lr3NMuA2MzjaY+qrh9cE4HVoKgJfLWwsc5nfec5Gy1m+IupTsXy+dJrlfp4 yMAA== X-Gm-Message-State: AO0yUKX2aQw0+r5stX36MWbHe8yLDwAZe3TXEP3ovz4ZAJ2UOiuK3F3H Q09Kot/LcZPy2fDZkHcnxKarPg== X-Google-Smtp-Source: AK7set914Wp5RL83mMnm7E4A70LS7FhgqF4nPI1GsnEFvR8wUvLLOem+xxJEfHU0e/zR0EAorfFrqw== X-Received: by 2002:a4a:1ac4:0:b0:51a:aa79:bc09 with SMTP id 187-20020a4a1ac4000000b0051aaa79bc09mr13080152oof.5.1678711251422; Mon, 13 Mar 2023 05:40:51 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:544b:2c1a:9dc0:2851:9b88? ([2804:1b3:a7c0:544b:2c1a:9dc0:2851:9b88]) by smtp.gmail.com with ESMTPSA id y13-20020a4ade0d000000b005251903c669sm3064568oot.13.2023.03.13.05.40.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 05:40:50 -0700 (PDT) Message-ID: Date: Mon, 13 Mar 2023 09:40:47 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v6 3/3] linux: Set internal DIR filepos as off64_t (BZ #23960, BZ #24050) Content-Language: en-US To: Paul Eggert , libc-alpha@sourceware.org, "Andreas K . Huettel" , Florian Weimer References: <20230302145732.2293756-1-adhemerval.zanella@linaro.org> <20230302145732.2293756-4-adhemerval.zanella@linaro.org> <75761f49-474e-6c3c-7029-03b30e83da3e@cs.ucla.edu> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <75761f49-474e-6c3c-7029-03b30e83da3e@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/03/23 18:41, Paul Eggert wrote: > On 2023-03-02 06:57, Adhemerval Zanella wrote: >> +      for (i = 0; i < dirstream_loc_size (&dirp->locs); i++) >> +    if (*dirstream_loc_at (&dirp->locs, i) == dirp->filepos) >> +      break; >> +      /* It should be pre-allocated on readdir.  */ >> +      assert (i != dirstream_loc_size (&dirp->locs)); > > This should be something like the following, to avoid unnecessary work when assertions are disabled: > >   for (long int i = 0; ; i++) >     { >       assert (i < dirstream_loc_size (&dirp->locs)); >       if (*dirstream_loc_at (&dirp->locs, i) == dirp->filepos) >     break; >     } > Ack, it works for me. >> +      /* This assignment might overflow, however most likely ENOME would >> +     happen long before.  */ >> +      dsp.p.info = i; > > This doesn't sound right. The allocator should never create a table with more than LONG_MAX entries because the upper part of any such table would be useless. If that is done right, the assignment cannot overflow. Indeed it does not make sense since it is based on malloc anyway. I will remove the comment. > >> +_Static_assert (sizeof (long int) == sizeof (off64_t), >> +        "sizeof (long int) != sizeof (off64_t)"); > > This is confusing. First, we need require only that long int be at least as wide as off64_t; it doesn't have to be exactly the same width. Second, why both "==" and "!="? Third, why not use plain "static_assert" with one arg instead of the old-fashioned "_Static_assert" with two? We can support this form of static_assert on older compilers - see how Gnulib does it. Indeed, we already set _DIRENT_OFFSET_TRANSLATION for (LONG_WIDTH < 64) so maybe I think we should replace with 64 with sizeof (off_64) and remove the static assert. > > >> +static __always_inline bool >> +telldir_need_dirstream (__off64_t d_off) >> +{ >> +  return d_off >= 1UL << 31; >> +} > > Safer would be '! (TYPE_MINIMUM (off_t) <= d_off && d_off <= TYPE_MAXIMUM (off_t))', in case d_off is negative (or off_t isn't 32-bit :-). Ack.