Skip to content

Next size_t stop: pack-objects/delta

Johannes Schindelin via GitGitGadget git 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest13 patches 1 replyIn review
  2. v212 patches 6 repliesSuperseded
  3. v112 patches 8 repliesSuperseded

Changes in v3 from the cover letter

* Now zlib_cap_buf() is also widened in this patch series (I had left this for a later one, originally).
* The unpack_object_header_buffer() function is now also widened in this here patch series.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/13diff-delta: widen `struct delta_index`' size fields to `size_t`delta.h diff-delta.c+5 -50 replies
2/13delta: widen `create_delta_index()` parameter to `size_t`delta.h diff-delta.c+2 -20 replies
3/13pack-objects: widen delta-cache accounting to `size_t`builtin/pack-objects.c config.c config.h +2 more+27 -50 replies
4/13pack-objects: widen `free_unpacked()` return to `size_t`builtin/pack-objects.c+2 -20 replies
5/13pack-objects: widen `mem_usage` and `try_delta()`'s out-param to `size_t`builtin/pack-objects.c+2 -20 replies
6/13delta: widen `create_delta()` and `diff_delta()` to `size_t`builtin/fast-import.c builtin/pack-objects.c delta.h +4 more+22 -150 replies
7/13packfile, git-zlib: widen `use_pack()` and zstream avail fields to `size_t`builtin/pack-objects.c git-zlib.c git-zlib.h +3 more+13 -120 replies
8/13archive-zip: widen `zlib_deflate_raw()`'s maxsize local to `size_t`archive-zip.c+1 -10 replies
9/13diff: widen `deflate_it()`'s bound local from int to `size_t`diff.c+1 -10 replies
10/13http-push: widen `start_put()`'s size local from `ssize_t` to `size_t`http-push.c+1 -10 replies
11/13t/helper/test-pack-deltas: widen `do_compress()`'s maxsize local to `size_t`t/helper/test-pack-deltas.c+1 -10 replies
12/13git-zlib: widen `git_deflate_bound()` to `size_t`git-zlib.c git-zlib.h+15 -30 replies
13/13packfile: widen `unpack_object_header_buffer()` to `size_t`builtin/pack-objects.c oss-fuzz/fuzz-pack-headers.c packfile.c +1 more+9 -120 replies

Reviews trailers per patch

None of the 13 patches has a Reviewed-by or Acked-by.

PatchPatrick Steinhardt
1/13Helped-by
2/13
3/13Helped-by
4/13
5/13
6/13
7/13
8/13
9/13
10/13
11/13
12/13
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 00/13] Next size_t stop: pack-objects/delta

This patch series continues the effort to stop using unsigned long where size_t should have been used in the first place. This makes a difference on 64-bit Windows, where unsigned long is 32-bit.

With these fixes, the pack-objects machinery works as intended on 64-bit Windows (and any other 64-bit platform where unsigned long isn't 64-bit).

Changes since v2:

* Now zlib_cap_buf() is also widened in this patch series (I had left this for a later one, originally).
* The unpack_object_header_buffer() function is now also widened in this here patch series.

Changes since v1:

* The return value of sizeof_delta_index() is now included in the unsigned long -> size_t work.
* To assign correct values to the now-widened max_delta_cache_size, a new pair of helpers are introduced and used: git_parse_size_t() and git_config_size_t()
* There are now two references regarding the provenance of the deflateBound() formula in the corresponding commit message.

Johannes Schindelin (13):
diff-delta: widen struct delta_index' size fields to size_t
delta: widen create_delta_index() parameter to size_t
pack-objects: widen delta-cache accounting to size_t
pack-objects: widen free_unpacked() return to size_t
pack-objects: widen mem_usage and try_delta()'s out-param to

    `size_t`
  delta: widen `create_delta()` and `diff_delta()` to `size_t`
  packfile, git-zlib: widen `use_pack()` and zstream avail fields to
    `size_t`
  archive-zip: widen `zlib_deflate_raw()`'s maxsize local to `size_t`
  diff: widen `deflate_it()`'s bound local from int to `size_t`
  http-push: widen `start_put()`'s size local from `ssize_t` to `size_t`
  t/helper/test-pack-deltas: widen `do_compress()`'s maxsize local to
    `size_t`

git-zlib: widen git_deflate_bound() to size_t
packfile: widen unpack_object_header_buffer() to size_t

 archive-zip.c                |  2 +-
 builtin/fast-import.c        |  6 ++++--
 builtin/pack-objects.c       | 32 ++++++++++++++++----------------
 config.c                     |  9 +++++++++
 config.h                     |  3 +++
 delta.h                      | 14 +++++++-------
 diff-delta.c                 | 14 +++++++-------
 diff.c                       |  6 ++++--
 git-zlib.c                   | 18 +++++++++++++++---
 git-zlib.h                   |  6 +++---
 http-push.c                  |  2 +-
 oss-fuzz/fuzz-pack-headers.c |  2 +-
 pack-check.c                 |  4 ++--
 packfile.c                   | 12 +++++-------
 packfile.h                   |  6 ++++--
 parse.c                      |  9 +++++++++
 parse.h                      |  1 +
 t/helper/test-delta.c        |  2 +-
 t/helper/test-pack-deltas.c  |  7 ++++---
 19 files changed, 97 insertions(+), 58 deletions(-)

base-commit: f85a7e662054a7b0d9070e432508831afa214b47
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2175%2Fdscho%2Fsize-t%2Fpack-objects-delta-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2175/dscho/size-t/pack-objects-delta-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/2175

Range-diff vs v2:

  1:  0012c1007b =  1:  0012c1007b diff-delta: widen `struct delta_index`' size fields to `size_t`
  2:  75500c5abb =  2:  75500c5abb delta: widen `create_delta_index()` parameter to `size_t`
  3:  5b54041baf =  3:  5b54041baf pack-objects: widen delta-cache accounting to `size_t`
  4:  9850de1a91 =  4:  9850de1a91 pack-objects: widen `free_unpacked()` return to `size_t`
  5:  c301958284 =  5:  c301958284 pack-objects: widen `mem_usage` and `try_delta()`'s out-param to `size_t`
  6:  cfbf6c9567 =  6:  cfbf6c9567 delta: widen `create_delta()` and `diff_delta()` to `size_t`
  7:  ca928b4579 !  7:  e4528f9034 packfile, git-zlib: widen `use_pack()` and zstream avail fields to `size_t`

@@ builtin/pack-objects.c: size_t oe_get_size_slow(struct packing_data *pack,
if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
size_t sz;

+ ## git-zlib.c ##
+@@ git-zlib.c: static const char *zerr_to_string(int status) +
+ /* uLong is 32-bit on Windows, even on 64-bit systems */
+ #define ULONG_MAX_VALUE maximum_unsigned_value_of_type(uLong) +-static inline uInt zlib_buf_cap(unsigned long len) ++static inline uInt zlib_buf_cap(size_t len)
+ {
+ return (ZLIB_BUF_MAX < len) ? ZLIB_BUF_MAX : len;
+ }
+
## git-zlib.h ##
@@

  8:  9f379ee7aa =  8:  4521a41ff6 archive-zip: widen `zlib_deflate_raw()`'s maxsize local to `size_t`
  9:  ff103a0ee1 =  9:  f0765f6ed6 diff: widen `deflate_it()`'s bound local from int to `size_t`
 10:  c701d2f9b2 = 10:  c91b4d7a7e http-push: widen `start_put()`'s size local from `ssize_t` to `size_t`
 11:  e6175d2d87 = 11:  f4f2fa75f4 t/helper/test-pack-deltas: widen `do_compress()`'s maxsize local to `size_t`
 12:  762e716afe = 12:  b4004b1067 git-zlib: widen `git_deflate_bound()` to `size_t`
  -:  ---------- > 13:  bc4a58336a packfile: widen `unpack_object_header_buffer()` to `size_t`
Signature · 1 line
gitgitgadget