MIPS: BCM47XX: Cast memcmp() of function to (void *)
Subsystems (2)
PATCH 1/1 MIPS: BCM47XX: Cast memcmp() of function to (void *)
Clang is especially sensitive about argument type matching when using __overloaded functions (like memcmp(), etc). Help it see that function pointers are just "void *". Avoids this error:
arch/mips/bcm47xx/prom.c:89:8: error: no matching function for call to 'memcmp'
if (!memcmp(prom_init, prom_init + mem, 32))
^~~~~~include/linux/string.h:156:12: note: candidate function not viable: no known conversion from 'void (void)' to 'const void *' for 1st argument extern int memcmp(const void *,const void *,__kernel_size_t);
--- arch/mips/bcm47xx/prom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/bcm47xx/prom.c +1 -1
@@ -86,7 +86,7 @@ static __init void prom_init_mem(void)pr_debug ("Assume 128MB RAM\n" );break ; } -if (!memcmp (prom_init, prom_init + mem,32 )) +if (!memcmp ((void *)prom_init, (void *)prom_init + mem,32 ))break ; } lowmem = mem;
Signature · 1 line
2.34.1
Quoted 9 lines · Kees Cook
Clang is especially sensitive about argument type matching when using
__overloadedfunctions (likememcmp(), etc). Help it see that function pointers are just "void *". Avoids this error:
arch/mips/bcm47xx/prom.c:89:8: error: no matching function for call to 'memcmp'if (!memcmp(prom_init, prom_init + mem, 32)) ^~~~~~
include/linux/string.h:156:12: note: candidate function not viable: no known conversion from 'void (void)' to 'const void *' for 1st argument extern intmemcmp(const void *,const void *,__kernel_size_t);
Don't we have the same problem at line 162?
(next-20220908)arch/mips/bcm47xx/prom.c:
161 for (extmem = 128 << 20; extmem < 512 << 20; extmem <<= 1) {
162 if (!memcmp(prom_init, (void *)(off + extmem), 16))
163 break;
164 }
--
Gustavo
Quoted 30 lines
Cc Hauke Mehrtens <[email protected]>Cc "Rafał Miłecki" <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Nathan Chancellor <[email protected]>Cc Nick Desaulniers <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Kees Cook <[email protected]>--- arch/mips/bcm47xx/prom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/bcm47xx/prom.c +1
-1@@ -86,7 +86,7 @@ static __init void prom_init_mem(void)pr_debug ("Assume 128MB RAM\n" );break ; } -if (!memcmp (prom_init, prom_init + mem,32 )) +if (!memcmp ((void *)prom_init, (void *)prom_init + mem,32 ))break ; } lowmem = mem;Signature · 1 line
2.34.1
Quoted 38 lines · Kees Cook
Clang is especially sensitive about argument type matching when using
__overloadedfunctions (likememcmp(), etc). Help it see that function pointers are just "void *". Avoids this error:
arch/mips/bcm47xx/prom.c:89:8: error: no matching function for call to 'memcmp'if (!memcmp(prom_init, prom_init + mem, 32)) ^~~~~~
include/linux/string.h:156:12: note: candidate function not viable: no known conversion from 'void (void)' to 'const void *' for 1st argument extern intmemcmp(const void *,const void *,__kernel_size_t);Cc Hauke Mehrtens <[email protected]>Cc "Rafał Miłecki" <[email protected]>Cc Thomas Bogendoerfer <[email protected]>Cc Nathan Chancellor <[email protected]>Cc Nick Desaulniers <[email protected]>Reported-by kernel test robot <[email protected]>Signed-off-by Kees Cook <[email protected]>--- arch/mips/bcm47xx/prom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/bcm47xx/prom.c +1
-1@@ -86,7 +86,7 @@ static __init void prom_init_mem(void)pr_debug ("Assume 128MB RAM\n" );break ; } -if (!memcmp (prom_init, prom_init + mem,32 )) +if (!memcmp ((void *)prom_init, (void *)prom_init + mem,32 ))break ; } lowmem = mem;Signature · 1 line
2.34.1
applied to mips-next with the second memcmp(prom_init changed as well.
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]