From: Patrick Steinhardt <ps@pks.im>
To: Christian Couder <christian.couder@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>,
Jeff King <peff@peff.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 2/3] odb: widen odb_write_object() length to size_t
Date: Wed, 18 Nov 2026 09:25:17 +0100 [thread overview]
Message-ID: <av1g7VQnCAcs5J1W@pks.im> (raw)
In-Reply-To: <20261117174353.1158905-7-christian.couder@gmail.com>
On Tue, Nov 17, 2026 at 06:43:56PM +0100, Christian Couder wrote:
> odb_write_object() and odb_write_object_ext() use an `unsigned long`
> for their object length argument, while almost everything they pass it
> to already uses `size_t`: hash_object_file(), format_object_header(),
> convert_object_file(), the `write_object` callback of `struct
> odb_source`, and `git_zstream`.
Huh, I thought that we already had patches recently that converted this
function to use `size_t`... oh, yes, this is overlapping with Elia's
patch series [1]. I think it would make sense to rebase your patch
series on top of his patches.
[1]: <20261021101640.329990-1-gitter.spiros@gmail.com>
[snip]
> To fix the possible truncation issues with many callers and to prepare
> for getting rid of the check, let's use `size_t` for:
>
> - the length argument of odb_write_object(), odb_write_object_ext(),
> the odb_source_write_object() wrapper, and write_loose_object(),
>
> - the size stored in `struct inmemory_object`, which is later
> copied back into `size_t` fields (`object_info.sizep` and
> `odb_stream.size`).
Yeah, makes sense.
> diff --git a/odb.c b/odb.c
> index de5be285d3..56a7910b03 100644
> --- a/odb.c
> +++ b/odb.c
> @@ -702,7 +702,7 @@ void odb_assert_oid_type(struct object_database *odb,
> }
>
> int odb_write_object_ext(struct object_database *odb,
> - const void *buf, unsigned long len,
> + const void *buf, size_t len,
> enum object_type type,
> struct object_id *oid,
> const struct object_id *compat_oid_in,
Right. All functions that we pass `len` to already accept a `size_t`,
except for `odb_source_write_object()`. But you also adapt that function
at the same time, so we're good.
> diff --git a/odb/source.h b/odb/source.h
> index 7b56f51b82..8daf5df31c 100644
> --- a/odb/source.h
> +++ b/odb/source.h
> @@ -454,7 +454,7 @@ static inline int odb_source_freshen_object(struct odb_source *source,
> * object ID and the compatibility object ID, if non-NULL.
> */
> static inline int odb_source_write_object(struct odb_source *source,
> - const void *buf, unsigned long len,
> + const void *buf, size_t len,
> enum object_type type,
> const struct object_id *oid,
> const struct object_id *compat_oid,
And the callback functions fo the backend already use a `size_t`, so
those don't need to be changed.
Patrick
next prev parent reply other threads:[~2026-11-18 8:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 17:43 [PATCH 0/3] Allow merges with results over 2 GiB on 64-bit Windows Christian Couder
2026-11-17 17:43 ` [PATCH 1/3] notes-merge: use size_t in write_buf_to_worktree() Christian Couder
2026-11-18 8:25 ` Patrick Steinhardt
2026-11-17 17:43 ` [PATCH 2/3] odb: widen odb_write_object() length to size_t Christian Couder
2026-11-18 8:25 ` Patrick Steinhardt [this message]
2026-11-17 17:43 ` [PATCH 3/3] xdiff: drop LONG_MAX check on merge result size Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=av1g7VQnCAcs5J1W@pks.im \
--to=ps@pks.im \
--cc=Johannes.Schindelin@gmx.de \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=kaartic.sivaraam@gmail.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox