[U-Boot] [PATCH] drivers/net/e1000.c: Fix GCC 4.6 build warnings

Moffett, Kyle D Kyle.D.Moffett at boeing.com
Tue Dec 20 17:07:30 CET 2011


On Dec 20, 2011, at 10:49, Anatolij Gustschin wrote:
> Fix:
> e1000.c: In function 'e1000_read_mac_addr':
> e1000.c:1149:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
> e1000.c:1149:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
[...]
> #ifdef CONFIG_E1000_FALLBACK_MAC
> -	if ( *(u32*)(nic->enetaddr) == 0 || *(u32*)(nic->enetaddr) == ~0 ) {
> +	if (get_unaligned_be32(nic->enetaddr) == 0 ||
> +	    get_unaligned_be32(nic->enetaddr) == ~0) {
> 		unsigned char fb_mac[NODE_ADDRESS_SIZE] = CONFIG_E1000_FALLBACK_MAC;
> 
> 		memcpy (nic->enetaddr, fb_mac, NODE_ADDRESS_SIZE);

No, if you are going to fix this code then make it use the right
function for the job: is_valid_ether_addr()

Furthermore, while the E1000 chipset does not generally work very
well without a proper SPI EEPROM image (if at all), I think it
would be better for the driver to load successfully and use the
"macaddr" from the U-Boot environment instead of some hardcoded
compile-time constant.

IE: That whole code block should be ripped out and instead just
tweak the "valid MAC address" check further down.

Cheers,
Kyle Moffett

--
Curious about my work on the Debian powerpcspe port?
I'm keeping a blog here: http://pureperl.blogspot.com/



More information about the U-Boot mailing list