From: Junio C Hamano <gitster@pobox.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] builtin/fsck.c: don't conflate "int" and "enum" in callback
Date: Wed, 02 Jun 2021 06:04:31 +0900 [thread overview]
Message-ID: <xmqq8s3ts3ds.fsf@gitster.g> (raw)
In-Reply-To: <patch-1.1-f109a61b11-20210601T000433Z-avarab@gmail.com> ("Ævar Arnfjörð Bjarmason"'s message of "Tue, 1 Jun 2021 02:05:59 +0200")
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Fix a warning on AIX's xlc compiler that's been emitted since my
> a1aad71601a (fsck.h: use "enum object_type" instead of "int",
> 2021-03-28):
>
> "builtin/fsck.c", line 805.32: 1506-068 (W) Operation between
> types "int(*)(struct object*,enum object_type,void*,struct
> fsck_options*)" and "int(*)(struct object*,int,void*,struct
> fsck_options*)" is not allowed.
>
> I.e. it complains about us assigning a function with a prototype "int"
> where we're expecting "enum object_type". Enums are just ints in C,
> but it seems xlc is more picky than some about conflating them at the
> source level.
As others already have pointed out, xlc is correct and these
warnings are perhaps useful. I'd just remove the last sentence
while queuing, as "Enums are just ints in C" is only half a truth.
The constants like OBJ_COMMIT can be used as "int", but the type of
an enum itself may not be the same as "int"---it can be narrower.
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
>
> This is new in v2.32.0, so sending this during the rc phase, just a
> warning though, so unless you're using fatal warnings on that
> OS/platform it won't impact anything, and even then it's just a minor
> annoyance...
Thanks.
>
> builtin/fsck.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/fsck.c b/builtin/fsck.c
> index 87a99b0108..b42b6fe21f 100644
> --- a/builtin/fsck.c
> +++ b/builtin/fsck.c
> @@ -109,7 +109,8 @@ static int fsck_error_func(struct fsck_options *o,
>
> static struct object_array pending;
>
> -static int mark_object(struct object *obj, int type, void *data, struct fsck_options *options)
> +static int mark_object(struct object *obj, enum object_type type,
> + void *data, struct fsck_options *options)
> {
> struct object *parent = data;
prev parent reply other threads:[~2021-06-01 21:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-01 0:05 [PATCH] builtin/fsck.c: don't conflate "int" and "enum" in callback Ævar Arnfjörð Bjarmason
2021-06-01 6:25 ` Johannes Sixt
2021-06-01 8:04 ` Ævar Arnfjörð Bjarmason
2021-06-01 17:56 ` René Scharfe
2021-06-01 21:04 ` Junio C Hamano [this message]
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=xmqq8s3ts3ds.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).