From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Patrick Steinhardt <ps@pks.im>, git@vger.kernel.org
Subject: Re: [PATCH 3/3] odb: drop gaps in object info flag values
Date: Mon, 26 Jan 2026 10:13:51 -0800 [thread overview]
Message-ID: <xmqqpl6wi6n4.fsf@gitster.g> (raw)
In-Reply-To: <add7c86f-9d5e-4136-8c3d-a04df523487b@web.de> ("René Scharfe"'s message of "Mon, 26 Jan 2026 19:02:15 +0100")
René Scharfe <l.s.r@web.de> writes:
>> I wonder if this series can be restructured a bit to demonstrate the
>> benefit of moving to enum a bit more prominently. For example, even
>> at the end of the three patches, odb_read_object_info_extended()
>> still takes an "unsigned flags" parameter, but it is meant to take
>> this new enum, isn't it? If we do the "#define to enum" conversion
>> (without renumbering) first, then "unsigned to enum", would it, with
>> appropriate compiler warning flags, already reveal the existing bugs
>> that happened to be working OK as potential problems? And with that,
>> fixes in 1/3 and 2/3 would demonstrate why #define to enum" is worth
>> doing very well. And after all that, we can renumber the enums in a
>> separate and final step.
> With -Wenum-conversion you can get GCC to report implicit conversions
> between different enum types (like in the backfill case), but I don't
> see a way to warn about conversions from int (the fsck case).
Yes, that is why I suggested "unsigned to enum" change after doing
"#define to enum" conversion. If a caller passes an enum with
HAS_OBJECT_* to odb_read_object_info_extended() that expects
"unsigned flags", it would not be warned, but if the callee expects
"enum object_info_flags", passing HAS_OBJECT_* enum to it would be
flagged, right? We may need to give the currently-unnamed enum with
HAS_OBJECT_* a name first.
> https://stackoverflow.com/questions/4669454/how-to-make-gcc-warn-about-passing-wrong-enum-to-a-function
> suggests using -Wenum-compare and macros to sneak in a comparison, but
> that doesn't seem to catch more than -Wenum-conversion, which doesn't
> need any macros.
>
> https://godbolt.org/z/Whvc7Mf1n
>
> Perhaps sparse can do that?
>
> René
next prev parent reply other threads:[~2026-01-26 18:13 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 12:17 [PATCH 0/3] Small fixups for `OBJECT_INFO` flags Patrick Steinhardt
2026-01-26 12:17 ` [PATCH 1/3] builtin/backfill: fix flags passed to `odb_has_object()` Patrick Steinhardt
2026-01-26 20:17 ` Derrick Stolee
2026-01-26 21:07 ` Junio C Hamano
2026-02-09 19:57 ` Justin Tobler
2026-02-10 9:24 ` Karthik Nayak
2026-02-10 9:32 ` Karthik Nayak
2026-01-26 12:17 ` [PATCH 2/3] builtin/fsck: " Patrick Steinhardt
2026-02-09 20:04 ` Justin Tobler
2026-01-26 12:17 ` [PATCH 3/3] odb: drop gaps in object info flag values Patrick Steinhardt
2026-01-26 16:58 ` Junio C Hamano
2026-01-26 18:02 ` René Scharfe
2026-01-26 18:13 ` Junio C Hamano [this message]
2026-01-27 6:29 ` Patrick Steinhardt
2026-02-09 20:32 ` Justin Tobler
2026-02-09 20:18 ` Justin Tobler
2026-01-26 16:28 ` [PATCH 0/3] Small fixups for `OBJECT_INFO` flags Junio C Hamano
2026-02-12 6:59 ` [PATCH v2 0/5] " Patrick Steinhardt
2026-02-12 6:59 ` [PATCH v2 1/5] builtin/backfill: fix flags passed to `odb_has_object()` Patrick Steinhardt
2026-02-12 6:59 ` [PATCH v2 2/5] builtin/fsck: " Patrick Steinhardt
2026-02-12 6:59 ` [PATCH v2 3/5] odb: drop gaps in object info flag values Patrick Steinhardt
2026-02-12 6:59 ` [PATCH v2 4/5] odb: convert object info flags into an enum Patrick Steinhardt
2026-02-12 6:59 ` [PATCH v2 5/5] odb: convert `odb_has_object()` " Patrick Steinhardt
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=xmqqpl6wi6n4.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--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