Browse Source

[atl1e] Fix compilation on gcc-4.4.1-2.fc11.i586.

Error message was:

[BUILD] bin/atl1e.oncc1: warnings being treated as errors
drivers/net/atl1e.c: In function 'atl1e_get_permanent_address':
drivers/net/atl1e.c:1326: error: dereferencing type-punned pointer will break strict-aliasing rules
make: *** [bin/atl1e.o] Error 1

Reported-by: Giandomenico  De Tullio <ghisha@email.it>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
Modified-by: Michael Brown <mcb30@etherboot.org>
tags/v1.0.0-rc1
Joshua Oreman 15 years ago
parent
commit
858b5fd253
1 changed files with 9 additions and 8 deletions
  1. 9
    8
      src/drivers/net/atl1e.c

+ 9
- 8
src/drivers/net/atl1e.c View File

@@ -1296,14 +1296,14 @@ void atl1e_hw_set_mac_addr(struct atl1e_hw *hw)
1296 1296
  */
1297 1297
 static int atl1e_get_permanent_address(struct atl1e_hw *hw)
1298 1298
 {
1299
-	u32 addr[2];
1299
+	union {
1300
+		u32 dword[2];
1301
+		u8 byte[8];
1302
+	} hw_addr;
1300 1303
 	u32 i;
1301 1304
 	u32 twsi_ctrl_data;
1302 1305
 	u8  eth_addr[ETH_ALEN];
1303 1306
 
1304
-	/* init */
1305
-	addr[0] = addr[1] = 0;
1306
-
1307 1307
 	if (!atl1e_check_eeprom_exist(hw)) {
1308 1308
 		/* eeprom exist */
1309 1309
 		twsi_ctrl_data = AT_READ_REG(hw, REG_TWSI_CTRL);
@@ -1320,10 +1320,11 @@ static int atl1e_get_permanent_address(struct atl1e_hw *hw)
1320 1320
 	}
1321 1321
 
1322 1322
 	/* maybe MAC-address is from BIOS */
1323
-	addr[0] = AT_READ_REG(hw, REG_MAC_STA_ADDR);
1324
-	addr[1] = AT_READ_REG(hw, REG_MAC_STA_ADDR + 4);
1325
-	*(u32 *) &eth_addr[2] = swap32(addr[0]);
1326
-	*(u16 *) &eth_addr[0] = swap16(*(u16 *)&addr[1]);
1323
+	hw_addr.dword[0] = AT_READ_REG(hw, REG_MAC_STA_ADDR);
1324
+	hw_addr.dword[1] = AT_READ_REG(hw, REG_MAC_STA_ADDR + 4);
1325
+	for (i = 0; i < ETH_ALEN; i++) {
1326
+		eth_addr[ETH_ALEN - i - 1] = hw_addr.byte[i];
1327
+	}
1327 1328
 
1328 1329
 	memcpy(hw->perm_mac_addr, eth_addr, ETH_ALEN);
1329 1330
 	return 0;

Loading…
Cancel
Save