[PATCH v2] libctf: ctf_member_next needs to return (ssize_t)-1 on error

Nick Alcock nick.alcock@oracle.com
Thu Sep 7 12:10:20 GMT 2023


On 30 Aug 2023, Alan Modra via Binutils outgrape:

> On Wed, Aug 30, 2023 at 10:34:05AM +0200, Torbjorn SVENSSON wrote:
>> @Alan, any additional comments on this updated patch (except the missing
>> semicolon that I mention below)?
>
> I'm leaving it to Nick Alcock to decide what to do here.

I agree that we should indeed be returning -1 from all functions that
return an int (it used to, but ctf_id_t has to be an unsigned long). But
I think it might be less disruptive to do so via a new
ctf_set_errno_int() which is just like ctf_set_errno but returns an int
rather than an unsigned long. That eliminates a lot of {}ery and makes
each individual hunk smaller.

My concern is that it's really hard to validate all this -- can anyone
think of a trick that would emit *consistent* warnings if we called
return (ctf_set_errno()) from a function returning int? I mean this
returning-int thing is a change I made ages ago, and despite making it
*and* attempting to validate on 64-bit Windows I have clearly not got it
right because it's drifted right out of correctness again.

(Similarly, does anyone have a build/target triplet on which this goes
wrong? because it's not going wrong on any of my mingw64 or cygwin tests
as far as I can tell.)

I kinda wish we could rely on having C11 -- type-generic macros are made
for cases like this :(

-- 
NULL && (void)


More information about the Binutils mailing list