From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 11/12] builtin/gc: fix signedness issues in ODB-related functionality
Date: Sun, 26 Jul 2026 09:25:33 -0700 [thread overview]
Message-ID: <xmqqwluhvhtu.fsf@gitster.g> (raw)
In-Reply-To: <amCmwKjbq2aNt8mZ@pks.im> (Patrick Steinhardt's message of "Wed, 22 Jul 2026 13:17:20 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> On Mon, Jul 13, 2026 at 09:28:02AM -0700, Junio C Hamano wrote:
>> Patrick Steinhardt <ps@pks.im> writes:
>> > diff --git a/builtin/gc.c b/builtin/gc.c
>> > index 3207182488..8cf3781313 100644
>> > --- a/builtin/gc.c
>> > @@ -456,7 +458,7 @@ static struct packed_git *find_base_packs(struct odb_source_files *files,
>> > if (e->pack->is_cruft)
>> > continue;
>> > if (limit) {
>> > - if (e->pack->pack_size >= limit)
>> > + if ((uintmax_t) e->pack->pack_size >= limit)
>>
>> Here, just like in too_many_loose_objects(), 'limit' is of type
>> 'unsigned long'. While it makes sense to convert both sides of
>> the comparison to an unsigned type, casting only the left side
>> to a type that differs from the right side puzzles me.
>>
>> Presumably, the other side is of type 'off_t', which is signed,
>> explaining the desire to cast it to an unsigned type. But I am
>> not sure what happens if 'off_t' is wider than 'unsigned long'.
>
> Yeah, `pack_size` is an `off_t`, which is signed. But we never populate
> it with a negative value, so casting it to `uintmax_t` in unnecessary.
> The right-hand side is already unsigned, so due to the usual arithmetic
> conversion rules it would be automatically promoted to `uintmax_t`, as
> well.
So we are in agreement that this hunk, unlike others, have little to
do with "fix signedness issues"?
I personally feel that the true fix in signedness issues is not to
use -Wsign-compare or teach compilers to be intelligent about when
to issue the warning when given that flag, but that is a separate
topic.
Thanks.
next prev parent reply other threads:[~2026-07-26 16:25 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 15:32 [PATCH 00/11] odb: make optimizations pluggable Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 01/11] odb: run "pre-auto-gc" hook for all maintenance tasks Patrick Steinhardt
2026-07-07 19:55 ` Junio C Hamano
2026-07-08 7:55 ` Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 02/11] builtin/gc: move worktree and rerere tasks before object optimizations Patrick Steinhardt
2026-07-07 20:27 ` Junio C Hamano
2026-07-07 15:32 ` [PATCH 03/11] builtin/gc: extract object database optimizations into separate function Patrick Steinhardt
2026-07-07 20:30 ` Junio C Hamano
2026-07-07 15:32 ` [PATCH 04/11] builtin/gc: make repack arguments self-contained Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 05/11] builtin/gc: inline config values specific to the "files" backend Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 06/11] builtin/gc: introduce object database optimization options Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 07/11] builtin/gc: move geometric repacking into `odb_optimize()` Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 08/11] builtin/gc: introduce `odb_optimize_required()` Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 09/11] builtin/gc: refactor ODB optimizations to operate on "files" source Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 10/11] builtin/gc: fix signedness issues in ODB-related functionality Patrick Steinhardt
2026-07-07 15:32 ` [PATCH 11/11] odb: make optimizations pluggable Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 00/12] " Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 01/12] t7900: simplify how we check for maintenance tasks Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 02/12] odb: run "pre-auto-gc" hook for all " Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 03/12] builtin/gc: move worktree and rerere tasks before object optimizations Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 04/12] builtin/gc: extract object database optimizations into separate function Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 05/12] builtin/gc: make repack arguments self-contained Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 06/12] builtin/gc: inline config values specific to the "files" backend Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 07/12] builtin/gc: introduce object database optimization options Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 08/12] builtin/gc: move geometric repacking into `odb_optimize()` Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 09/12] builtin/gc: introduce `odb_optimize_required()` Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 10/12] builtin/gc: refactor ODB optimizations to operate on "files" source Patrick Steinhardt
2026-07-13 5:52 ` [PATCH v2 11/12] builtin/gc: fix signedness issues in ODB-related functionality Patrick Steinhardt
2026-07-13 16:28 ` Junio C Hamano
2026-07-22 11:17 ` Patrick Steinhardt
2026-07-26 16:25 ` Junio C Hamano [this message]
2026-07-13 5:52 ` [PATCH v2 12/12] odb: make optimizations pluggable Patrick Steinhardt
2026-07-13 16:34 ` Junio C Hamano
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=xmqqwluhvhtu.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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