![]() |
|
Message-ID: <068fbfc4-8e72-4aba-a708-96a63fbd1e06@brad-house.com>
Date: Thu, 18 Jul 2024 15:19:57 -0400
From: Brad House <brad@...d-house.com>
To: musl@...ts.openwall.com
Subject: Re: [PATCH 1/1] FD_SET() and FD_ISSET() warn on
-Wsign-conversion
On 7/18/24 12:25 PM, Rich Felker wrote:
>> We really can't wrap FD_SET/FD_ISSET in c-ares, since wrapping it
>> would require the library to know the internals about the operations
>> of the fd_set for each and every platform, which could change over
>> time if there are ABI changes.
>>
>> I understand your concern regarding casting away real programming
>> errors by accident. The only solution to that I see would be to
>> turn the macros into functions, POSIX says either are valid:https://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/select.h.html
>>
>> Of course, that would introduce a backwards-incompatible ABI change
>> where an application compiled against a newer version of musl
>> wouldn't run on an older version. I don't know what your ABI
>> policies look like to know if that's acceptable.
> That's not acceptable, but I think you're confusing "functions" with
> "functions with external linkage". There's no reason you can't do
> functions with static linkage. However there is probably also some
> fancy solution with the ternary operator that avoids the
> type-unsafety. I haven't thought through the pros and cons of either
> option.
You are right, replacing a complex macro with a static inline function
in a header might be acceptable and keep full ABI compatibility. That
said, I've always considered static inlines in headers to be a bad
practice in general, but there are always exceptions to the rule.
You'd also have the ability to do bounds checking with a function, such
(d < 0 || d >= FD_SETSIZE) which would be good for preventing out of
bounds reads and writes.
-Brad
Content of type "text/html" skipped
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.