Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH8yC8=FwbLvLq0+NLxc3O+i+Bm7iWowapZK+gayT1O+pLgF5g@mail.gmail.com>
Date: Fri, 23 May 2025 12:07:13 -0400
From: Jeffrey Walton <noloader@...il.com>
To: musl@...ts.openwall.com
Cc: david@...ackrest.org
Subject: Re: Sign conversion warning in FD_ISSET()

On Fri, May 23, 2025 at 11:31 AM David Steele <david@...ackrest.org> wrote:
>
> Greetings,
>
> I'm getting a warning when compiling on Alpine 3.21 with musl libc 1.2.5:
>
> # /lib/libc.musl-aarch64.so.1
> musl libc (aarch64)
> Version 1.2.5
>
> The code looks like this (simplified for this example, see original at
> (https://github.com/pgbackrest/pgbackrest/blob/release/2.55.1/src/protocol/parallel.c#L163):
>
> int fd = getFdFunc();
>
> if (FD_ISSET(fd, &selectSet))
>
> And I get this warning when -Wsign-conversion is enabled on gcc:
>
> ../../pgbackrest/src/protocol/parallel.c:164:25: error: conversion to
> 'long unsigned int' from 'int' may change the sign of the result
> [-Werror=sign-conversion]
>    164 |                     if (FD_ISSET(fd, &selectSet))
>
> Here's the cc output from ninja:
>
> [3/4] cc -Isrc/pgbackrest.p -Isrc -I../../pgbackrest/src
> -Isrc/command/help -Isrc/postgres -I/usr/include/postgresql
> -I/usr/include/libxml2 -fdiagnostics-color=always -DNDEBUG
> -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c99 -O3
> -Wcast-qual -Wconversion -Wduplicated-cond -Wduplicated-branches
> -Wformat=2 -Wformat-overflow=2 -Wformat-signedness -Winit-self
> -Wmissing-prototypes -Wmissing-variable-declarations -Wpointer-arith
> -Wredundant-decls -Wstrict-prototypes -Wvla -Wwrite-strings
> -Wno-clobbered -Wno-missing-field-initializers -funroll-loops
> -ftree-vectorize -fmacro-prefix-map=../../pgbackrest/src/=
> -fmacro-prefix-map=../../pgbackrest/test/src/=test/
> -D_POSIX_C_SOURCE=200809L -MD -MQ src/pgbackrest.p/protocol_parallel.c.o
> -MF src/pgbackrest.p/protocol_parallel.c.o.d -o
> src/pgbackrest.p/protocol_parallel.c.o -c
> ../../pgbackrest/src/protocol/parallel.c
>
> I can fix this by casting to long unsigned int, but it seems like
> FD_ISSET() should accept int without complaint like the associate macros
> and functions.
>
> Please CC me on any response since I am not subscribed to the mailing list.

For some background, see the discussion at
<https://www.openwall.com/lists/musl/2024/07/16/1>.

Jeff

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.