bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 12/41] libps: Silence a warning


From: Jessica Clarke
Subject: Re: [PATCH 12/41] libps: Silence a warning
Date: Wed, 10 May 2023 01:44:39 +0100

On 10 May 2023, at 01:26, Samuel Thibault <samuel.thibault@gnu.org> wrote:
> 
> Sergey Bugaev, le mar. 09 mai 2023 00:31:07 +0300, a ecrit:
>> GCC was complaining about the mismatch in types between the 'fn' pointer
>> and the function pointers assigned to it. Since fn is meant to be used
>> with different function types, represent it as a 'void *' and not a
>> pointer to any particular function type.
>> ---
>> libps/ps.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/libps/ps.h b/libps/ps.h
>> index 192847b5..3e59c66a 100644
>> --- a/libps/ps.h
>> +++ b/libps/ps.h
>> @@ -535,7 +535,7 @@ struct ps_getter
>> 
>>     /* A function that will get the value; the protocol between this function
>>        and its caller is type-dependent.  */
>> -    void (*fn) (void);
>> +    void *fn;
> 
> Mmm, IIRC, strictly speaking, a function pointer is not the same as a
> pointer, on some odd archs such as ia64 it makes a difference.

That’s not quite true. It’s not a direct pointer to the instructions,
but it is still a normal pointer. POSIX dlsym means that function
pointers need to fit in void * (but ISO C doesn’t). However, if your
pointer is a function, it should be a function pointer, with casts
added as needed (which ISO C permits, provided when you make the call
it’s cast back to the right type).

Jess




reply via email to

[Prev in Thread] Current Thread [Next in Thread]