Re: [PATCH 2/7] patch-delta: use size_t for sizes
From: Patrick Steinhardt <hidden>
Date: 2026-06-08 13:53:27
On Thu, Jun 04, 2026 at 10:51:07AM +0000, Johannes Schindelin via GitGitGadget wrote:
From: Johannes Schindelin <redacted> `patch_delta()` takes the source and delta sizes by value and writes back the reconstructed target size through an `unsigned long *`. That datatype cannot represent a value that exceeds 4 GiB on systems where `unsigned long` is 32-bit (notably 64-bit Windows builds), though, even though the delta encoding itself, the on-disk layout, and the in-memory buffers happily carry such sizes. A `size_t` companion to `get_delta_hdr_size()`, `get_delta_hdr_size_sz()`, was introduced in 17fa077596 (delta, packfile: use size_t for delta header sizes, 2026-05-08) precisely so that `patch_delta()` could be widened without changing the on-the-wire decoding helper's signature. Widen `patch_delta()`'s three size parameters to `size_t` and switch its internal use of `get_delta_hdr_size()` to the `_sz` variant. Then propagate the wider type through the callers.
Does `get_delta_hdr_size()` have any remaining callers after this patch series? I currently only spot two such callers, and you convert both of them in this patch. And can we reasonably add a test case that exercises this change?
quoted hunk ↗ jump to hunk
diff --git a/packfile.c b/packfile.c index 89366abfe3..e202f48837 100644 --- a/packfile.c +++ b/packfile.c@@ -1964,10 +1964,8 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset, (uintmax_t)curpos, p->pack_name); data = NULL; } else { - unsigned long sz; data = patch_delta(base, base_size, delta_data, - delta_size, &sz); - size = sz; + delta_size, &size);
Nice that we get rid of this awkward construct. Patrick