[Spam] [PATCH 1/2] kexec-tools: powerpc: Fix function signature of comparefunc()

Khalid Aziz khalid at gonehiking.org
Wed Oct 22 08:32:23 PDT 2025


On 10/22/25 9:20 AM, John Paul Adrian Glaubitz wrote:
> Hi Khalid,
> 
> On Wed, 2025-10-22 at 09:15 -0600, Khalid Aziz wrote:
>> On 10/22/25 5:44 AM, John Paul Adrian Glaubitz wrote:
>>> Fixes the following build error on 32-bit PowerPC:
>>>
>>> kexec/arch/ppc/fs2dt.c: In function 'putnode':
>>> kexec/arch/ppc/fs2dt.c:338:51: error: passing argument 4 of 'scandir' from incompatible pointer type [-Wincompatible-pointer-types]
>>>     338 |         numlist = scandir(pathname, &namelist, 0, comparefunc);
>>>         |                                                   ^~~~~~~~~~~
>>>         |                                                   |
>>>         |                                                   int (*)(const void *, const void *)
>>>
>>> Signed-off-by: John Paul Adrian Glaubitz <glaubitz at physik.fu-berlin.de>
>>
>> I sent out a suggested patch yesterday making these same changes. They make sense to me.
> 
> Yes, I actually saw your patch after submitting my patches. ;-)
> 
>>> ---
>>>    kexec/arch/ppc/fs2dt.c | 3 ++-
>>>    1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/kexec/arch/ppc/fs2dt.c b/kexec/arch/ppc/fs2dt.c
>>> index fed499b..d03b995 100644
>>> --- a/kexec/arch/ppc/fs2dt.c
>>> +++ b/kexec/arch/ppc/fs2dt.c
>>> @@ -292,7 +292,8 @@ static void putprops(char *fn, struct dirent **nlist, int numlist)
>>>     * Compare function used to sort the device-tree directories
>>>     * This function will be passed to scandir.
>>>     */
>>> -static int comparefunc(const void *dentry1, const void *dentry2)
>>> +static int comparefunc(const struct dirent **dentry1,
>>> +		       const struct dirent **dentry2)
>>>    {
>>>    	char *str1 = (*(struct dirent **)dentry1)->d_name;
>>>    	char *str2 = (*(struct dirent **)dentry2)->d_name;
>>
>> You can drop typecasting in above two lines as well:
>>
>> -    char *str1 = (*(struct dirent **)dentry1)->d_name;
>> -    char *str2 = (*(struct dirent **)dentry2)->d_name;
>> +    char *str1 = (*dentry1)->d_name;
>> +    char *str2 = (*dentry2)->d_name;
> 
> That's right. However, that should be done in a separate patch which would
> also do the same for comparefunc() in kexec/fs2dt.c so that changes that
> logically belong together are submitted as one patch.

Okay, I can see that. It also makes sense to drop typecast in kexec/arch/ppc/kexec-ppc.c
in the same patch that changes comparefunc declaration. I don't feel strongly about
either approach and can go either way. You can add my reviewed by tag:

Reviewed-by: Khalid Aziz <khalid at gonehiking.org>

> 
> My changes above are the minimal changes required to fix the build on 32-bit
> PowerPC which I tested on the Debian powerpc/ppc64 porterbox.
> 
> Once the two patches are merged, I'm happy to submit one to drop the two
> type-casting changes in both instances of comparefunc().
> 
> There are also some warnings that I will look into and address them.

Yes, there are lots of build warnings :) I chose to ignore those for now and get
this building first. I am glad you are looking at those.

> 
> Adrian
> 
--Khalid



More information about the kexec mailing list