linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ethernet: 3c515: Fix cast from pointer to integer of different size
@ 2020-01-04 14:33 Krzysztof Kozlowski
  2020-01-04 14:33 ` [PATCH 2/2] net: ethernet: ni65: " Krzysztof Kozlowski
  2020-01-06 21:31 ` [PATCH 1/2] net: ethernet: 3c515: " David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-01-04 14:33 UTC (permalink / raw)
  To: David S. Miller, Krzysztof Kozlowski, netdev, linux-kernel

Pointer passed as integer should be cast to unsigned long to
avoid warning (compile testing on alpha architecture):

    drivers/net/ethernet/3com/3c515.c: In function ‘corkscrew_start_xmit’:
    drivers/net/ethernet/3com/3c515.c:1066:8: warning:
        cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Only compile tested
---
 drivers/net/ethernet/3com/3c515.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/3com/3c515.c b/drivers/net/ethernet/3com/3c515.c
index 1e233e2f0a5a..f5b4cacef07a 100644
--- a/drivers/net/ethernet/3com/3c515.c
+++ b/drivers/net/ethernet/3com/3c515.c
@@ -1063,7 +1063,7 @@ static netdev_tx_t corkscrew_start_xmit(struct sk_buff *skb,
 #ifdef VORTEX_BUS_MASTER
 	if (vp->bus_master) {
 		/* Set the bus-master controller to transfer the packet. */
-		outl((int) (skb->data), ioaddr + Wn7_MasterAddr);
+		outl((unsigned long)(skb->data), ioaddr + Wn7_MasterAddr);
 		outw((skb->len + 3) & ~3, ioaddr + Wn7_MasterLen);
 		vp->tx_skb = skb;
 		outw(StartDMADown, ioaddr + EL3_CMD);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: ethernet: ni65: Fix cast from pointer to integer of different size
  2020-01-04 14:33 [PATCH 1/2] net: ethernet: 3c515: Fix cast from pointer to integer of different size Krzysztof Kozlowski
@ 2020-01-04 14:33 ` Krzysztof Kozlowski
  2020-01-06 21:31 ` [PATCH 1/2] net: ethernet: 3c515: " David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-01-04 14:33 UTC (permalink / raw)
  To: David S. Miller, Krzysztof Kozlowski, netdev, linux-kernel

"buffer" array is unsigned long so casting of pointer to u32 causes
warning (compile testing on alpha architecture):

    drivers/net/ethernet/amd/ni65.c: In function ‘ni65_stop_start’:
    drivers/net/ethernet/amd/ni65.c:751:16: warning:
        cast from pointer to integer of different size [-Wpointer-to-int-cast]

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>

---

Only compile tested
---
 drivers/net/ethernet/amd/ni65.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/ni65.c b/drivers/net/ethernet/amd/ni65.c
index c38edf6f03a3..60c194680bdf 100644
--- a/drivers/net/ethernet/amd/ni65.c
+++ b/drivers/net/ethernet/amd/ni65.c
@@ -748,7 +748,7 @@ static void ni65_stop_start(struct net_device *dev,struct priv *p)
 #ifdef XMT_VIA_SKB
 			skb_save[i] = p->tmd_skb[i];
 #endif
-			buffer[i] = (u32) isa_bus_to_virt(tmdp->u.buffer);
+			buffer[i] = (unsigned long)isa_bus_to_virt(tmdp->u.buffer);
 			blen[i] = tmdp->blen;
 			tmdp->u.s.status = 0x0;
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: ethernet: 3c515: Fix cast from pointer to integer of different size
  2020-01-04 14:33 [PATCH 1/2] net: ethernet: 3c515: Fix cast from pointer to integer of different size Krzysztof Kozlowski
  2020-01-04 14:33 ` [PATCH 2/2] net: ethernet: ni65: " Krzysztof Kozlowski
@ 2020-01-06 21:31 ` David Miller
  2020-01-07  8:35   ` Krzysztof Kozlowski
  1 sibling, 1 reply; 4+ messages in thread
From: David Miller @ 2020-01-06 21:31 UTC (permalink / raw)
  To: krzk; +Cc: netdev, linux-kernel

From: Krzysztof Kozlowski <krzk@kernel.org>
Date: Sat,  4 Jan 2020 15:33:05 +0100

> Pointer passed as integer should be cast to unsigned long to
> avoid warning (compile testing on alpha architecture):
> 
>     drivers/net/ethernet/3com/3c515.c: In function ‘corkscrew_start_xmit’:
>     drivers/net/ethernet/3com/3c515.c:1066:8: warning:
>         cast from pointer to integer of different size [-Wpointer-to-int-cast]
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> 
> ---
> 
> Only compile tested

Sorry, I'm not applying these two.

It is clear that these drivers only work properly on 32-bit architectures
where virtual address equals the DMA address.

Making this warning goes away creates a false sense that they are in
fact 64-bit clean and capable, they are not.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: ethernet: 3c515: Fix cast from pointer to integer of different size
  2020-01-06 21:31 ` [PATCH 1/2] net: ethernet: 3c515: " David Miller
@ 2020-01-07  8:35   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2020-01-07  8:35 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, linux-kernel

On Mon, Jan 06, 2020 at 01:31:55PM -0800, David Miller wrote:
> From: Krzysztof Kozlowski <krzk@kernel.org>
> Date: Sat,  4 Jan 2020 15:33:05 +0100
> 
> > Pointer passed as integer should be cast to unsigned long to
> > avoid warning (compile testing on alpha architecture):
> > 
> >     drivers/net/ethernet/3com/3c515.c: In function ‘corkscrew_start_xmit’:
> >     drivers/net/ethernet/3com/3c515.c:1066:8: warning:
> >         cast from pointer to integer of different size [-Wpointer-to-int-cast]
> > 
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > 
> > ---
> > 
> > Only compile tested
> 
> Sorry, I'm not applying these two.
> 
> It is clear that these drivers only work properly on 32-bit architectures
> where virtual address equals the DMA address.
> 
> Making this warning goes away creates a false sense that they are in
> fact 64-bit clean and capable, they are not.

The existing casts are clearly wrong - the convention is that pointer
should be cast to unsigned long, not int. In the second case it is even
weirder - the buffer array is actually unsigned long so the cast is
confusing.

However I understand your argument that these casts serve as a
documentation purpose of only 32-bit support, so let it be.

Thanks!

Best regards,
Krzysztof


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-01-07  8:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-04 14:33 [PATCH 1/2] net: ethernet: 3c515: Fix cast from pointer to integer of different size Krzysztof Kozlowski
2020-01-04 14:33 ` [PATCH 2/2] net: ethernet: ni65: " Krzysztof Kozlowski
2020-01-06 21:31 ` [PATCH 1/2] net: ethernet: 3c515: " David Miller
2020-01-07  8:35   ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).