Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <093BA4CA-2774-449D-902F-D786017CD6AF@aevum.de>
Date: Fri, 6 Jun 2025 02:28:47 +0200
From: Nick Wellnhofer <wellnhofer@...um.de>
To: musl@...ts.openwall.com
Cc: Rich Felker <dalias@...c.org>,
 David Steele <david@...ackrest.org>,
 noloader@...il.com
Subject: Re: Sign conversion warning in FD_ISSET()

On Jun 6, 2025, at 02:23, Andy Caldwell <andy.m.caldwell@...glemail.com> wrote:
> 
>>> There probably is some way to get it right with clever use of the
>>> ternary operator but I haven't come up with anything in the first few
>>> seconds thinking about it.
>>> 
>>> Rich
> 
> Yes, the ternary operator can be used to create a C89-compatible
> version (this allows anything coercible to an `int` or an `unsigned`,
> so it mostly only refuses pointers and structures).
> 
> #define SOCKET_TO_UNSIGNED(s) ((unsigned)(1?(s):0))

This doesn't work with pointers because 0 is a null pointer constant. But if you change the value to 1, it should work.

Nick

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.