* [PATCH] bootwrapper: mspsc.c: fix pointer-to-int-cast warnings
@ 2017-10-05 11:28 Michal Suchanek
2017-11-13 11:05 ` Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Michal Suchanek @ 2017-10-05 11:28 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Michal Suchanek, linuxppc-dev, linux-kernel
I get these warnings:
../arch/powerpc/boot/mpsc.c: In function 'mpsc_get_virtreg_of_phandle':
../arch/powerpc/boot/mpsc.c:113:35: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
../arch/powerpc/boot/mpsc.c: In function 'mpsc_console_init':
../arch/powerpc/boot/mpsc.c:147:12: warning: cast from pointer to
integer of different size [-Wpointer-to-int-cast]
Presumably the patch below fixes these, and presumably the DT defines
that pointes and integers have the same size in the DT so this is fine
regardless of 32bit/64bit target. I have not found a DT definition for
PowerPC, howewer. So any bugs in the property sizing and resulting
failures to read the properties are left as before.
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
arch/powerpc/boot/mpsc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/boot/mpsc.c b/arch/powerpc/boot/mpsc.c
index 425ad88cce8d..ea740493277a 100644
--- a/arch/powerpc/boot/mpsc.c
+++ b/arch/powerpc/boot/mpsc.c
@@ -110,7 +110,7 @@ static volatile char *mpsc_get_virtreg_of_phandle(void *devp, char *prop)
if (n != sizeof(v))
goto err_out;
- devp = find_node_by_linuxphandle((u32)v);
+ devp = find_node_by_linuxphandle((intptr_t)v);
if (devp == NULL)
goto err_out;
@@ -144,7 +144,7 @@ int mpsc_console_init(void *devp, struct serial_console_data *scdp)
n = getprop(devp, "cell-index", &v, sizeof(v));
if (n != sizeof(v))
goto err_out;
- reg_set = (int)v;
+ reg_set = (intptr_t)v;
mpscintr_base += (reg_set == 0) ? 0x4 : 0xc;
--
2.10.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] bootwrapper: mspsc.c: fix pointer-to-int-cast warnings
2017-10-05 11:28 [PATCH] bootwrapper: mspsc.c: fix pointer-to-int-cast warnings Michal Suchanek
@ 2017-11-13 11:05 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2017-11-13 11:05 UTC (permalink / raw)
To: Michal Suchanek, Benjamin Herrenschmidt, Paul Mackerras,
Michal Suchanek, linuxppc-dev, linux-kernel
Hi Michal,
Thanks for trying to fix this.
Michal Suchanek <msuchanek@suse.de> writes:
> I get these warnings:
>
> ../arch/powerpc/boot/mpsc.c: In function 'mpsc_get_virtreg_of_phandle':
> ../arch/powerpc/boot/mpsc.c:113:35: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>
> ../arch/powerpc/boot/mpsc.c: In function 'mpsc_console_init':
> ../arch/powerpc/boot/mpsc.c:147:12: warning: cast from pointer to
> integer of different size [-Wpointer-to-int-cast]
>
> Presumably the patch below fixes these, and presumably the DT defines
> that pointes and integers have the same size in the DT so this is fine
Actually no it doesn't. A device tree doesn't contain pointers, and it
doesn't say anything about the size of a pointer on a platform that uses
that device tree.
phandles are not pointers, they are handles, and they are always 32-bit.
So this code is just wrong on 64-bit, you can't safely cast from a
64-bit pointer to a phandle.
But I think this warning has actually been fixed differently by commit:
866bfc75f40e ("powerpc: conditionally compile platform-specific serial drivers")
If you're still seeing the warning let me know.
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-13 11:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-05 11:28 [PATCH] bootwrapper: mspsc.c: fix pointer-to-int-cast warnings Michal Suchanek
2017-11-13 11:05 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®