tree-walk: widen init_tree_desc() and init_tree_desc_gently() to size_t

Prep for dropping the cast_size_t_to_ulong() shim in
add_preferred_base() (pack-objects.c), and aligns the public API
with the size_t shape the rest of the tree topic is moving toward.

struct tree_desc.size stays unsigned int -- the on-disk tree format
hard-caps each tree at 4 GiB, so the field is intentionally narrow
and the assignment in init_tree_desc_internal() already truncated
unsigned long inputs the same way it now truncates size_t inputs.
The widening is purely about the call-side type-correctness; the
internal cap is unchanged.

All 30+ callers pass values that promote cleanly (unsigned long,
size_t, or smaller integer types).

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2026-06-05 20:11:56 +02:00
committed by Git for Windows Build Agent
parent 1cf9bfc086
commit 8eb5340be9
2 changed files with 5 additions and 5 deletions

View File

@@ -49,7 +49,7 @@ static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned l
static int init_tree_desc_internal(struct tree_desc *desc,
const struct object_id *oid,
const void *buffer, unsigned long size,
const void *buffer, size_t size,
struct strbuf *err,
enum tree_desc_flags flags)
{
@@ -63,7 +63,7 @@ static int init_tree_desc_internal(struct tree_desc *desc,
}
void init_tree_desc(struct tree_desc *desc, const struct object_id *tree_oid,
const void *buffer, unsigned long size)
const void *buffer, size_t size)
{
struct strbuf err = STRBUF_INIT;
if (init_tree_desc_internal(desc, tree_oid, buffer, size, &err, 0))
@@ -72,7 +72,7 @@ void init_tree_desc(struct tree_desc *desc, const struct object_id *tree_oid,
}
int init_tree_desc_gently(struct tree_desc *desc, const struct object_id *oid,
const void *buffer, unsigned long size,
const void *buffer, size_t size,
enum tree_desc_flags flags)
{
struct strbuf err = STRBUF_INIT;

View File

@@ -85,10 +85,10 @@ int update_tree_entry_gently(struct tree_desc *);
* members of `struct tree`.
*/
void init_tree_desc(struct tree_desc *desc, const struct object_id *tree_oid,
const void *buf, unsigned long size);
const void *buf, size_t size);
int init_tree_desc_gently(struct tree_desc *desc, const struct object_id *oid,
const void *buf, unsigned long size,
const void *buf, size_t size,
enum tree_desc_flags flags);
/*