git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Turner <David.Turner@twosigma.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: git <git@vger.kernel.org>
Subject: RE: [PATCH] http.postbuffer: make a size_t
Date: Fri, 31 Mar 2017 15:52:35 +0000	[thread overview]
Message-ID: <8d9af9884ccc4f99a01da863cb7ba600@exmbdft7.ad.twosigma.com> (raw)
In-Reply-To: <d312abfe-f87d-3940-ecfa-348fed7ad3a1@web.de>

> -----Original Message-----
> From: Torsten Bögershausen [mailto:tboegi@web.de]
> Sent: Friday, March 31, 2017 12:22 AM
> To: David Turner <David.Turner@twosigma.com>; git@vger.kernel.org
> Subject: Re: [PATCH] http.postbuffer: make a size_t
> 
> 
> 
> On 30/03/17 22:29, David Turner wrote:
> > Unfortunately, in order to push some large repos, the http postbuffer
> > must sometimes exceed two gigabytes.  On a 64-bit system, this is OK:
> > we just malloc a larger buffer.
> >
> > Signed-off-by: David Turner <dturner@twosigma.com>
> > ---
> >  cache.h  |  1 +
> >  config.c | 17 +++++++++++++++++
> >  http.c   |  2 +-
> >  3 files changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/cache.h b/cache.h
> > index fbdf7a815a..a8c1b65db0 100644
> > --- a/cache.h
> > +++ b/cache.h
> > @@ -1900,6 +1900,7 @@ extern int git_parse_maybe_bool(const char *);
> > extern int git_config_int(const char *, const char *);  extern int64_t
> > git_config_int64(const char *, const char *);  extern unsigned long
> > git_config_ulong(const char *, const char *);
> > +extern size_t git_config_size_t(const char *, const char *);
> >  extern int git_config_bool_or_int(const char *, const char *, int *);
> > extern int git_config_bool(const char *, const char *);  extern int
> > git_config_maybe_bool(const char *, const char *); diff --git
> > a/config.c b/config.c index 1a4d85537b..7b706cf27a 100644
> > --- a/config.c
> > +++ b/config.c
> > @@ -834,6 +834,15 @@ int git_parse_ulong(const char *value, unsigned
> long *ret)
> >  	return 1;
> >  }
> >
> > +static size_t git_parse_size_t(const char *value, unsigned long *ret)
> > +{
> > +	size_t tmp;
> > +	if (!git_parse_signed(value, &tmp,
> maximum_unsigned_value_of_type(size_t)))
> > +		return 0;
> > +	*ret = tmp;
> > +	return 1;
> > +}
> What is the return value here ?
> Isn't it a size_t we want ?

Yeah, that should return an int, since it's just "parsed" vs "unparsed".

> (There was a recent discussion about "unsigned long" vs "size_t", which
>   are the same on many systems, but not under Win64) Would the following
> work ?
> 
> static int git_parse_size_t(const char *value, size_t *ret) {
> 	if (!git_parse_signed(value, ret,
> maximum_unsigned_value_of_type(size_t)))
> 		return 0;
> 	return 1;
> }
> 
> []
> > +size_t git_config_size_t(const char *name, const char *value) {
> > +	unsigned long ret;
> > +	if (!git_parse_size_t(value, &ret))
> > +		die_bad_number(name, value);
> > +	return ret;
> > +}
> > +
> Same here:
> size_t git_config_size_t(const char *name, const char *value) {
> 	size_t ret;
> 	if (!git_parse_size_t(value, &ret))
> 		die_bad_number(name, value);
> 	return ret;
> }

In v2 I decided to make this a ssize_t, since it was previously a signed int.  I know we're not using negative values right now, but since nobody has 2**63 bytes of ram anyway, it's probably safe to keep it signed to keep our options open.

      reply	other threads:[~2017-03-31 15:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-30 20:29 [PATCH] http.postbuffer: make a size_t David Turner
2017-03-30 20:42 ` Shawn Pearce
2017-03-30 20:59   ` David Turner
2017-03-30 22:07 ` Junio C Hamano
2017-03-31  4:22 ` Torsten Bögershausen
2017-03-31 15:52   ` David Turner [this message]

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=8d9af9884ccc4f99a01da863cb7ba600@exmbdft7.ad.twosigma.com \
    --to=david.turner@twosigma.com \
    --cc=git@vger.kernel.org \
    --cc=tboegi@web.de \
    /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).