Hi,

On 2025-03-18 11:03:36 -0400, Tom Lane wrote:
> Andres Freund <and...@anarazel.de> writes:
> > aio: Add core asynchronous I/O infrastructure
> 
> Some of the buildfarm is mildly unhappy with this.
> So far I see
> 
>  ayu           | 2025-03-18 13:08:04 | aio_callback.c:83:12: warning: 
> comparison of constant 1 with expression of type 'PgAioHandleCallbackID' (aka 
> 'enum PgAioHandleCallbackID') is always false 
> [-Wtautological-constant-out-of-range-compare]
>  ayu           | 2025-03-18 13:08:04 | aio_callback.c:190:56: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  ayu           | 2025-03-18 13:08:04 | aio_callback.c:220:56: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  ayu           | 2025-03-18 13:08:04 | aio_callback.c:274:56: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  ayu           | 2025-03-18 13:08:04 | aio_target.c:50:41: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  ayu           | 2025-03-18 13:08:04 | aio_target.c:110:41: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  demoiselle    | 2025-03-18 03:43:46 | aio_callback.c:83:12: warning: 
> comparison of constant 1 with expression of type 'PgAioHandleCallbackID' (aka 
> 'enum PgAioHandleCallbackID') is always false 
> [-Wtautological-constant-out-of-range-compare]
>  demoiselle    | 2025-03-18 03:43:46 | aio_callback.c:190:56: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  demoiselle    | 2025-03-18 03:43:46 | aio_callback.c:220:56: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  demoiselle    | 2025-03-18 03:43:46 | aio_callback.c:274:56: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  demoiselle    | 2025-03-18 03:43:46 | aio_target.c:50:41: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]
>  demoiselle    | 2025-03-18 03:43:46 | aio_target.c:110:41: warning: 
> comparison of constant 1 with expression of type 'PgAioTargetID' (aka 'enum 
> PgAioTargetID') is always true [-Wtautological-constant-out-of-range-compare]

Thanks for noticing that.


> I don't have that compiler handy to check, but maybe changes like
> 
> -     if (cb_id >= lengthof(aio_handle_cbs))
> +     if ((size_t) cb_id >= lengthof(aio_handle_cbs))
> 
> would silence these?

I wonder if we should instead either ask those buildfarm animals to be
disabled or have the warning manually disabled. I don't think it's a good
investment on our part to work towards warning cleanliness on clang 4 and 5,
on distros from 2017 and and 2018 respectively.


> Or you could just drop all those tests and have faith in the type-safety of
> the enums.

The issue isn't really the type-safety of the enums (not that I would have a
lot of trust in that), it's whether the relevant callback/target actually have
been added to the the callback/target arrays.

Greetings,

Andres Freund


Reply via email to