git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] builtin/fsck.c: don't conflate "int" and "enum" in callback

From
Johannes Sixt <j6t@kdbg.org>
Date
Jun 1, 2021, 06:25 UTC
Message-ID
<de9dea3a-6138-5e2f-7dc8-8a2ddf28bb84@kdbg.org>
In-Reply-To
<patch-1.1-f109a61b11-20210601T000433Z-avarab@gmail.com>
Am 01.06.21 um 02:05 schrieb Ævar Arnfjörð Bjarmason:
Show 13 quoted lines
> 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.

Is that true? I thought compilers were allowed to use whatever data type is sufficient to represent all enumeration values. For this reason, you sometimes see

   enum X { A, B, X_MAX = 0x7fffffff };

that ensures that an int must be used for representation of enum X. So, AFAICS, your patch is an actual fix, not just cosmetic.

Show 27 quoted lines
> 
> 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...
> 
>  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;
>  
> 
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 2 of 5 in “builtin/fsck.c: don't conflate "int" and "enum" in callback”
  1. builtin/fsck.c: don't conflate "int" and "enum" in callbackÆvar Arnfjörð Bjarmason, Jun 1, 2021
  2. Johannes SixtJun 1, 2021
  3. Ævar Arnfjörð BjarmasonJun 1, 2021
  4. René ScharfeJun 1, 2021
  5. Junio C HamanoJun 1, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.