Skip to contentSkip to conversation

net: rtl8169: Build warning fixes for 64-bit

PATCH New Stephen Warren 2 participants 5 messages Oct 2, 2015 – Oct 29, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: rtl8169: Build warning fixes for 64-bit

From: Stephen Warren <[email protected]>

Casting from dev->priv to pci_dev_t changes the value's size on a 64-bit system. This causes the compiler to complain about casting a pointer to an integer of a different (smaller) size. To avoid this, cast to an integer of matching size first, then perform an int->int cast to perform the size change. This signals explicitly that we do want to change the size, and avoids the compiler warning. This is legitimate since we know the pointer actually stores a small integer, not a pointer value.

---
 drivers/net/rtl8169.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/rtl8169.c +6 -4
index ebd46b27e5fd..19422c4a2ace 100644
@@ -581,7 +581,8 @@ int rtl8169_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 #else
 static int rtl_recv(struct eth_device *dev)
 {
-	return rtl_recv_common((pci_dev_t)dev->priv, dev->iobase, NULL);
+	return rtl_recv_common((pci_dev_t)(unsigned long)dev->priv,
+			       dev->iobase, NULL);
 }
 #endif /* nCONFIG_DM_ETH */
 
@@ -666,8 +667,8 @@ int rtl8169_eth_send(struct udevice *dev, void *packet, int length)
 #else
 static int rtl_send(struct eth_device *dev, void *packet, int length)
 {
-	return rtl_send_common((pci_dev_t)dev->priv, dev->iobase, packet,
-			       length);
+	return rtl_send_common((pci_dev_t)(unsigned long)dev->priv,
+			       dev->iobase, packet, length);
 }
 #endif
 
@@ -846,7 +847,8 @@ RESET - Finish setting up the ethernet interface
 ***************************************************************************/
 static int rtl_reset(struct eth_device *dev, bd_t *bis)
 {
-	rtl8169_common_start((pci_dev_t)dev->priv, dev->enetaddr);
+	rtl8169_common_start((pci_dev_t)(unsigned long)dev->priv,
+			     dev->enetaddr);
 
 	return 0;
 }
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 net: rtl8169: Build warning fixes for 64-bit

Quoted 11 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Casting from dev->priv to pci_dev_t changes the value's size on a 64-bit system. This causes the compiler to complain about casting a pointer to an integer of a different (smaller) size. To avoid this, cast to an integer of matching size first, then perform an int->int cast to perform the size change. This signals explicitly that we do want to change the size, and avoids the compiler warning. This is legitimate since we know the pointer actually stores a small integer, not a pointer value.

#2 lore raw

PATCH 1/1 net: rtl8169: Build warning fixes for 64-bit

Quoted 11 lines · Joe Hershberger
Quoted 10 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Casting from dev->priv to pci_dev_t changes the value's size on a 64-bit system. This causes the compiler to complain about casting a pointer to an integer of a different (smaller) size. To avoid this, cast to an integer of matching size first, then perform an int->int cast to perform the size change. This signals explicitly that we do want to change the size, and avoids the compiler warning. This is legitimate since we know the pointer actually stores a small integer, not a pointer value.

Quoted 3 lines
Quoted 1 line

Joe, this patch appears to be assigned to you in patchwork. Will you apply it now the merge window is open, or are you assuming it will go through the Tegra tree with all the PCIe patches?

#3 lore raw

PATCH 1/1 net: rtl8169: Build warning fixes for 64-bit

Hi Stephen,

Quoted 19 lines · Stephen Warren
Quoted 18 lines · Joe Hershberger
Quoted 13 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Casting from dev->priv to pci_dev_t changes the value's size on a 64-bit system. This causes the compiler to complain about casting a pointer to an
integer of a different (smaller) size. To avoid this, cast to an integer of matching size first, then perform an int->int cast to perform the size change. This signals explicitly that we do want to change the size, and avoids the compiler warning. This is legitimate since we know the pointer actually stores a small integer, not a pointer value.

Quoted 6 lines
Quoted 1 line

Joe, this patch appears to be assigned to you in patchwork. Will you apply it now the merge window is open, or are you assuming it will go through the Tegra tree with all the PCIe patches?

I'll pull it in soon.

-Joe

#4 lore raw

PATCH 1/1 net: rtl8169: Build warning fixes for 64-bit

In reply to Stephen Warren
Quoted 11 lines · Stephen Warren

From: Stephen Warren <[email protected]>

Casting from dev->priv to pci_dev_t changes the value's size on a 64-bit system. This causes the compiler to complain about casting a pointer to an integer of a different (smaller) size. To avoid this, cast to an integer of matching size first, then perform an int->int cast to perform the size change. This signals explicitly that we do want to change the size, and avoids the compiler warning. This is legitimate since we know the pointer actually stores a small integer, not a pointer value.

Applied to u-boot-net/master, thanks!
-Joe