public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Anatolij Gustschin <agust@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] drivers/net/e1000.c: Fix GCC 4.6 build warnings
Date: Tue, 20 Dec 2011 18:26:28 +0100	[thread overview]
Message-ID: <20111220182628.2c418612@wker> (raw)
In-Reply-To: <8469240E-6A43-417F-844C-670CE1D373B5@boeing.com>

On Tue, 20 Dec 2011 10:07:30 -0600
"Moffett, Kyle D" <Kyle.D.Moffett@boeing.com> wrote:

> 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()

You are right, I'll fix it using 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.

The config option is documented in README:
	CONFIG_E1000_FALLBACK_MAC
		default MAC for empty EEPROM after production.

I assume this block is only for a possibility to use the driver
until the eeprom is programmed with a valid mac address.

Thanks,
Anatolij

  parent reply	other threads:[~2011-12-20 17:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-20 15:49 [U-Boot] [PATCH] drivers/net/e1000.c: Fix GCC 4.6 build warnings Anatolij Gustschin
2011-12-20 16:07 ` Moffett, Kyle D
2011-12-20 17:20   ` Mike Frysinger
2011-12-20 17:26   ` Anatolij Gustschin [this message]
2011-12-20 17:36 ` [U-Boot] [PATCH v2] " Anatolij Gustschin
2011-12-20 17:44   ` Moffett, Kyle D
2011-12-20 22:21   ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111220182628.2c418612@wker \
    --to=agust@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox