From: Wolfgang Denk Date: Tue, 19 Aug 2008 21:03:48 +0200 Subject: [U-Boot] [PATCH v4] fdt: rework fdt_fixup_ethernet() to use env instead of bd_t In-Reply-To: <1219163066-27896-1-git-send-email-galak@kernel.crashing.org> References: <1219163066-27896-1-git-send-email-galak@kernel.crashing.org> Message-ID: <20080819190349.09F4024899@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Kumar Gala, In message <1219163066-27896-1-git-send-email-galak@kernel.crashing.org> you wrote: > Move to using the environment variables 'ethaddr', 'eth1addr', etc.. > instead of bd->bi_enetaddr, bi_enet1addr, etc. > > This makes the code a bit more flexible to the number of ethernet > interfaces. > > Signed-off-by: Kumar Gala > --- > > Iterate over the aliases since its simplier than inventing a wheel to > iterate over the environment. This removes the hard coded limit. Please iterate over the environment variables as discussed earlier. I don't think there is any need to invent wheels to iterate over the environment. It should probably be as simple as that: char mac[16]; char *val; int i = 0; strcpy (mac, "ethaddr"); while ((val = getenv(mac)) != NULL) { ... sprintf (mac, "eth%daddr", ++i); } I call that a loop, not a wheel :-) > + sprintf(mac, idx ? "eth%daddr" : "ethaddr", idx); That should generate a nasty compiler warning about number of arguments ... Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de War is never imperative. -- McCoy, "Balance of Terror", stardate 1709.2