git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] Support sizes >=2G in various config options accepting 'g' sizes.

From
Nix <nix@esperi.org.uk>
Date
Sep 5, 2011, 13:56 UTC
Message-ID
<87ty8rm6th.fsf@spindle.srvr.nix>
In-Reply-To
<CAGdFq_gFNHq9Cgv4F4Q6VQ=G7odfUJ5pUFWn=OYE-BfXzP=Enw@mail.gmail.com>
On 5 Sep 2011, Sverre Rabbelier said:
Show 11 quoted lines
> Heya,
>
> On Mon, Sep 5, 2011 at 13:45, Nix <nix@esperi.org.uk> wrote:
>> 32-bit platforms with no type larger than 'long' cannot detect this
>> case and will continue to silently misbehave, but the misbehaviour
>> will be somewhat different and more useful, since bigFileThreshold was
>> also being mistakenly treated as a signed value when it should have
>> been unsigned.
>
> Is it not possible to detect that the target value won't fit in the
> max size of an int when parsing the config value?

Well, we're parsing longs, not ints. If sizeof(long)>sizeof(int), or we have long long and sizeof(long long)>sizeof(int), then we can always detect overflows when saving into the appropriate type: but if we don't have long long, or if we have neither strto(u)ll() nor strto[ui]max(), we could only detect overflow by looking at the raw text string and checking it by hand to see if it would fit. I judged this pointless extra complexity for a very rare edge case (machines with neither strot(u)ll() nor strto[ui]max() are generally quite old and people aren't going to be specifying sizes in gigabytes on such machines anyway.)

-- 
NULL && (void)
Previous: Sverre RabbelierNext: Clemens Buchacher
Message 4 of 12 in “Add strtoimax() compatibility function.”
  1. 1/2 Add strtoimax() compatibility function.Nix, Sep 5, 2011
  2. 2/2 Support sizes >=2G in various config options accepting 'g' sizes.Nix, Sep 5, 2011
  3. Sverre RabbelierSep 5, 2011
  4. NixSep 5, 2011
  5. Clemens BuchacherSep 6, 2011
  6. NixSep 6, 2011
  7. Johannes SixtSep 6, 2011
  8. NixSep 6, 2011
  9. Johannes SixtSep 6, 2011
  10. NixSep 6, 2011
  11. Junio C HamanoSep 6, 2011
  12. NixSep 6, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.