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

Re: [PATCH] http.postbuffer: make a size_t

From
Torsten Bögershausen <tboegi@web.de>
Date
Mar 31, 2017, 04:22 UTC
Message-ID
<d312abfe-f87d-3940-ecfa-348fed7ad3a1@web.de>
In-Reply-To
<20170330202917.24281-1-dturner@twosigma.com>
On 30/03/17 22:29, David Turner wrote:
Show 39 quoted lines
> 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 ?
(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;
}
[]
Show 8 quoted lines
> +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;
}
Previous: Junio C HamanoNext: David Turner
Message 5 of 6 in “http.postbuffer: make a size_t”
  1. http.postbuffer: make a size_tDavid Turner, Mar 30, 2017
  2. Shawn PearceMar 30, 2017
  3. David TurnerMar 30, 2017
  4. Junio C HamanoMar 30, 2017
  5. Torsten BögershausenMar 31, 2017
  6. David TurnerMar 31, 2017

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.