kexec-tools: powerpc: Fix function signature of comparefunc()
Subsystems (2)
PATCH 1/2 kexec-tools: powerpc: Fix function signature of comparefunc()
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 *)--- kexec/arch/ppc/fs2dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kexec/arch/ppc/fs2dt.c +2 -1
@@ -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;
Signature · 1 line
2.47.3
PATCH 2/2 kexec-tools: powerpc: Fix pointer declarations in read_memory_region_limits()
Fixes the following two build errors on 32-bit PowerPC:
kexec/arch/ppc/kexec-ppc.c: In function 'read_memory_region_limits':kexec/arch/ppc/kexec-ppc.c:106:11: error: assignment to 'long long unsigned int *' from incompatible pointer type 'long unsigned int *' [-Wincompatible-pointer-types]
106 | p = (unsigned long*)buf;
| ^
kexec/arch/ppc/kexec-ppc.c: In function 'read_memory_region_limits':kexec/arch/ppc/kexec-ppc.c:112:19: error: assignment to 'long unsigned int *' from incompatible pointer type 'long long unsigned int *' [-Wincompatible-pointer-types]
112 | p = (unsigned long long *)p + 1;
| ^
--- kexec/arch/ppc/kexec-ppc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kexec/arch/ppc/kexec-ppc.c +2 -2
@@ -91,7 +91,7 @@ int read_memory_region_limits(int fd, unsigned long long *start, unsigned long long *end) {char buf[MAXBYTES ]; -unsigned long *p; +unsigned long long *p;unsigned long nbytes = dt_address_cells + dt_size_cells;if (lseek (fd,0 ,SEEK_SET ) ==-1 ) {
@@ -103,7 +103,7 @@ int read_memory_region_limits(int fd, unsigned long long *start,return -1 ; } - p = (unsigned long *)buf; + p = (unsigned long long *)buf;if (dt_address_cells ==sizeof (unsigned long )) { *start = p[0 ]; p++;
Signature · 1 line
2.47.3
Quoted 10 lines · John Paul Adrian Glaubitz
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 <[email protected]>
I sent out a suggested patch yesterday making these same changes. They make sense to me.
Quoted 9 lines
--- kexec/arch/ppc/fs2dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kexec/arch/ppc/fs2dt.c +0
-0
kexec/arch/ppc/fs2dt.c static void putprops(char *fn, struct dirent **nlist, int numlist) · line 299
Quoted 9 lines
kexec/arch/ppc/fs2dt.c +2
-1@@ -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;
--
Khalid
Hi Khalid,
Quoted 10 lines · Khalid Aziz
Quoted 9 lines · John Paul Adrian Glaubitz
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 *)
Quoted 3 lines
Quoted 1 line
Signed-off-by John Paul Adrian Glaubitz <[email protected]>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. ;-)
Quoted 21 lines
Quoted 9 lines
--- kexec/arch/ppc/fs2dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kexec/arch/ppc/fs2dt.c +0
-0kexec/arch/ppc/fs2dt.c static void putprops(char *fn, struct dirent **nlist, int numlist) · line 299
Quoted 9 lines
kexec/arch/ppc/fs2dt.c +2
-1@@ -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:
Review
Quoted 4 lines
(quoted diff) +2
-2- 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.
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.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Khalid Aziz
Reviewed-byQuoted 40 lines · John Paul Adrian Glaubitz
Hi Khalid,
Quoted 10 lines · Khalid Aziz
Quoted 9 lines · John Paul Adrian Glaubitz
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 *)Quoted 3 lines
Quoted 1 line
Signed-off-by John Paul Adrian Glaubitz <[email protected]>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. ;-)
Quoted 21 lines
Quoted 9 lines
--- kexec/arch/ppc/fs2dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kexec/arch/ppc/fs2dt.c +0
-0kexec/arch/ppc/fs2dt.c static void putprops(char *fn, struct dirent **nlist, int numlist) · line 299
Quoted 9 lines
kexec/arch/ppc/fs2dt.c +2
-1@@ -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:
Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +2
-2- 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()inkexec/fs2dt.cso 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:
Quoted 8 lines
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.
Quoted 3 lines
Adrian
--Khalid
Quoted 10 lines · John Paul Adrian Glaubitz
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 <[email protected]>
Thanks,
I was able to reproduce this using gcc-powerpc-linux-gnu 4:14.2.0-1 on Debian Trixie. Likewise for patch 2/2.
There is a CI workflow that exercises 32-bit PowerPC builds [1]. However, it does not exhibit the problems reported.
I guess that is because it is using an older GCC, gcc-powerpc-linux-gnu 4:13.2.0-7ubuntu1 on Ubuntu 24.04.
[1] https://github.com/horms/kexec-tools/actions/runs/18554906205/job/52889935741
It would be nice to update the job,
but perhaps that is something that comes with Ubuntu 26.04.
In any case I have applied this series:
- kexec-tools: powerpc: Fix pointer declarations in read_memory_region_limits()
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=6c878e9b8a50
- kexec-tools: powerpc: Fix function signature of comparefunc()
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=2786f8eb3e5e
Quoted 19 lines · John Paul Adrian Glaubitz
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 <[email protected]>--- kexec/arch/ppc/fs2dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)kexec/arch/ppc/fs2dt.c +0
-0
kexec/arch/ppc/fs2dt.c static void putprops(char *fn, struct dirent **nlist, int numlist) · line 299
Quoted 9 lines
kexec/arch/ppc/fs2dt.c +2
-1@@ -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;
Ping for both patches.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Quoted 15 lines · John Paul Adrian Glaubitz
Quoted 14 lines · John Paul Adrian Glaubitz
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 <[email protected]>--- kexec/arch/ppc/fs2dt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 16 lines
Quoted 5 lines
kexec/arch/ppc/fs2dt.c +0
-0kexec/arch/ppc/fs2dt.c static void putprops(char *fn, struct dirent **nlist, int numlist) · line 299
Quoted 9 lines
kexec/arch/ppc/fs2dt.c +2
-1@@ -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;Ping for both patches.
Perhaps this email [1] got lost somehow?
[1] https://lore.kernel.org/kexec/[email protected]/
FTR, they have been applied as:
- kexec-tools: powerpc: Fix pointer declarations in read_memory_region_limits()
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=6c878e9b8a50
- kexec-tools: powerpc: Fix function signature of comparefunc()
https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/commit/?id=2786f8eb3e5e