Re: [PATCH 2/5] http: use `size_t` for byte position in fwrite_sha1_file
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Oct 16, 2026, 08:38 UTC
- Message-ID
- <atHiiye4oi_lF5FP@pks.im>
- In-Reply-To
- <70a909de18e8cd8d282439fb51a9399baa8c7be8.1791958171.git.gitgitgadget@gmail.com>
On Wed, Oct 14, 2026 at 06:09:28AM +0000, Johannes Schindelin via GitGitGadget wrote:
Show 12 quoted lines
> diff --git a/http.c b/http.c
> index 4af3c29c76..809471f436 100644
> --- a/http.c
> +++ b/http.c
> @@ -2848,7 +2848,7 @@ static size_t fwrite_sha1_file(char *ptr, size_t eltsize, size_t nmemb,
> {
> unsigned char expn[4096];
> size_t size = eltsize * nmemb;
> - int posn = 0;
> + size_t posn = 0;
> struct http_object_request *freq = data;
> struct active_request_slot *slot = freq->slot;Right. This is how we access the variable:
do {
ssize_t retval = xwrite(freq->localfile,
(char *) ptr + posn, size - posn);
if (retval < 0)
return posn / eltsize;
posn += retval;
} while (posn < size);So it's clear that it doesn't have to be signed either, as we only ever add positive values to it.
Patrick