git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nix <nix@esperi.org.uk>
To: Clemens Buchacher <drizzd@aon.at>
Cc: Sverre Rabbelier <srabbelier@gmail.com>, git@vger.kernel.org
Subject: Re: [PATCH 2/2] Support sizes >=2G in various config options accepting 'g' sizes.
Date: Tue, 06 Sep 2011 10:13:20 +0100	[thread overview]
Message-ID: <87ty8qjaof.fsf@spindle.srvr.nix> (raw)
In-Reply-To: <20110906074421.GB28490@ecki> (Clemens Buchacher's message of "Tue, 6 Sep 2011 09:44:21 +0200")

On 6 Sep 2011, Clemens Buchacher uttered the following:

> On Mon, Sep 05, 2011 at 02:56:10PM +0100, Nix wrote:
>> 
>> 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.)
>
> Is this also true for Windows and other platforms?

There, uintmax_t is 'long long' and is longer than 'long', let alone
'int', so this holds there too, or should.

> And I don't think it's about whether or not people are likely to
> specify sizes in gigabytes on old machines. People are bound to
> blindly copy configuration files from one machine to another. In
> any case, my expectation would be for the configuration options to
> do what I tell them, or error out if they do not make sense.

Yeah, and we do that whenever practically possible: but fixing
this for the case that int/long is the largest available type
(which among other things implies that we're not using GCC or
any other C99 compiler or any of the myriad C89 compilers that
implmented 'long long') amounts to writing our own strtol()
specifically for this one case, to see if the parsed number is
too long. And that is probably a maintenance burden too far.

The failure mode if you put a huge number in on such a platform is
better than it used to be, too, especially for core.bigfilethreshold. We
used to get a negative number that was latched to zero, which then
disabled compression entirely (I had an 83Mb pack turn itself into an
837Mb one when that happened). Now we get a number that, while positive,
is less positive than we expect, but still likely up in the hundreds of
millions.

-- 
NULL && (void)

  reply	other threads:[~2011-09-06  9:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-05 11:45 [PATCH 1/2] Add strtoimax() compatibility function Nix
2011-09-05 11:45 ` [PATCH 2/2] Support sizes >=2G in various config options accepting 'g' sizes Nix
2011-09-05 13:49   ` Sverre Rabbelier
2011-09-05 13:56     ` Nix
2011-09-06  7:44       ` Clemens Buchacher
2011-09-06  9:13         ` Nix [this message]
2011-09-06 10:22           ` Johannes Sixt
2011-09-06 10:25             ` Nix
2011-09-06 10:38               ` Johannes Sixt
2011-09-06 11:17                 ` Nix
2011-09-06  6:19 ` [PATCH 1/2] Add strtoimax() compatibility function Junio C Hamano
2011-09-06  9:14   ` Nix
  -- strict thread matches above, loose matches on Subject: below --
2011-11-02 15:46 [PATCH 0/2] Support sizes >=2G in various config options, v2 Nick Alcock
2011-11-02 15:46 ` [PATCH 2/2] Support sizes >=2G in various config options accepting 'g' sizes Nick Alcock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ty8qjaof.fsf@spindle.srvr.nix \
    --to=nix@esperi.org.uk \
    --cc=drizzd@aon.at \
    --cc=git@vger.kernel.org \
    --cc=srabbelier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).