From: Holger Freyther Date: Mon, 14 Jan 2013 15:16:29 +0000 (UTC) Subject: [U-Boot] =?utf-8?q?=5BPATCH_v3=5D_davinci=3A_cleanup_davinci=5Fsy?= =?utf-8?q?nc=5Fenv=5Fenetaddr=28=29=09fucntion?= References: <1328853158-4616-1-git-send-email-manjunath.hadli@ti.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Manjunath Hadli ti.com> writes: > > check for the return status for eth_getenv_enetaddr_by_index() > and eth_setenv_enetaddr() functions and print appropriate message > on failure. I am upgrading from v2011.12 (as I have some ubifsmount issues and don't want to debug this on an old ubi) and I saw that setting the MAC address from EEPROM is broken. > - if (!memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { > + ret = eth_getenv_enetaddr_by_index("eth", 0, env_enetaddr); > + if (ret) { In case there is no mac address in the environment the net/eth.c code will set env_enetaddr to all 0. This means that is_valid_ether_addr inside eth_getenv_enetaddr will return 0 (as of not valid). That also means that the below function will not be called. I assume the right fix is to change the condition to !ret. > - eth_setenv_enetaddr("ethaddr", rom_enetaddr); > + ret = !eth_setenv_enetaddr("ethaddr", rom_enetaddr); > } > + if (!ret) > + printf("Failed to set mac address from EEPROM\n"); adding %d for 'ret' would be nice.