Skip to contentSkip to conversation

net: tsec - fix dereferencing type-punned pointer will break strict-aliasing rules warning

PATCH Superseded Kim Phillips 2 participants 4 messages Jun 15, 2009 – Jul 21, 2009 2 messages not in the archive Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: tsec - fix dereferencing type-punned pointer will break strict-aliasing rules warning

fix this gcc 4.4 warning:

tsec.c: In function 'tsec_init':
tsec.c:200: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 drivers/net/tsec.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/tsec.c +4 -1
index 399116f..40b3be4 100644
@@ -197,7 +197,10 @@ int tsec_init(struct eth_device *dev, bd_t * bd)
 	for (i = 0; i < MAC_ADDR_LEN; i++) {
 		tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->enetaddr[i];
 	}
-	regs->macstnaddr1 = *((uint *) (tmpbuf));
+	tempval = (tmpbuf[3] << 24) | (tmpbuf[2] << 16) | (tmpbuf[1] << 8) |
+		  tmpbuf[0];
+
+	regs->macstnaddr1 = tempval;
 
 	tempval = *((uint *) (tmpbuf + 4));
 
Signature · 1 line
1.6.3.2
Applied
#1 lore raw

PATCH 1/1 net: tsec - fix dereferencing type-punned pointer will break strict-aliasing rules warning

Quoted 17 lines · Kim Phillips

fix this gcc 4.4 warning:

tsec.c: In function 'tsec_init':
tsec.c:200: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 drivers/net/tsec.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/tsec.c +0 -0
index 399116f..40b3be4 100644
@@ -197,7 +197,10 @@ int tsec_init(struct eth_device *dev, bd_t * bd)
 	for (i = 0; i < MAC_ADDR_LEN; i++) {

drivers/net/tsec.c int tsec_init(struct eth_device *dev, bd_t * bd) · line 206

Quoted 10 lines
drivers/net/tsec.c +4 -1
 		tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->enetaddr[i];
 	}
-	regs->macstnaddr1 = *((uint *) (tmpbuf));
+	tempval = (tmpbuf[3] << 24) | (tmpbuf[2] << 16) | (tmpbuf[1] << 8) |
+		  tmpbuf[0];
+
+	regs->macstnaddr1 = tempval;
 
 	tempval = *((uint *) (tmpbuf + 4));
 

Applied to net repo.

thanks,
Ben

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

PATCH v2 1/1 net: tsec - fix dereferencing type-punned pointer will break strict-aliasing rules warning

fix this gcc 4.4 warning:

tsec.c: In function 'tsec_init':
tsec.c:200: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
this is the endian-correct version

 drivers/net/tsec.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/tsec.c +4 -1
index 63fc02e..5dc05e5 100644
@@ -197,7 +197,10 @@ int tsec_init(struct eth_device *dev, bd_t * bd)
 	for (i = 0; i < MAC_ADDR_LEN; i++) {
 		tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->enetaddr[i];
 	}
-	regs->macstnaddr1 = *((uint *) (tmpbuf));
+	tempval = (tmpbuf[0] << 24) | (tmpbuf[1] << 16) | (tmpbuf[2] << 8) |
+		  tmpbuf[3];
+
+	regs->macstnaddr1 = tempval;
 
 	tempval = *((uint *) (tmpbuf + 4));
 
Signature · 1 line
1.6.3.3
Applied
#5 lore raw

PATCH v2 1/1 net: tsec - fix dereferencing type-punned pointer will break strict-aliasing rules warning

Kim,

Quoted 19 lines · Kim Phillips

fix this gcc 4.4 warning:

tsec.c: In function 'tsec_init':
tsec.c:200: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
this is the endian-correct version

 drivers/net/tsec.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/tsec.c +0 -0
index 63fc02e..5dc05e5 100644
@@ -197,7 +197,10 @@ int tsec_init(struct eth_device *dev, bd_t * bd)
 	for (i = 0; i < MAC_ADDR_LEN; i++) {

drivers/net/tsec.c int tsec_init(struct eth_device *dev, bd_t * bd) · line 206

Quoted 10 lines
drivers/net/tsec.c +4 -1
 		tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->enetaddr[i];
 	}
-	regs->macstnaddr1 = *((uint *) (tmpbuf));
+	tempval = (tmpbuf[0] << 24) | (tmpbuf[1] << 16) | (tmpbuf[2] << 8) |
+		  tmpbuf[3];
+
+	regs->macstnaddr1 = tempval;
 
 	tempval = *((uint *) (tmpbuf + 4));
 

Applied to net repo.

thanks,
Ben