From: Wolfgang Denk Date: Thu, 05 May 2011 21:48:07 +0200 Subject: [U-Boot] [PATCH v6 4/5] Put common autoload code into auto_load() function In-Reply-To: References: <1304614330-20085-1-git-send-email-sjg@chromium.org> <1304614330-20085-4-git-send-email-sjg@chromium.org> Message-ID: <20110505194807.3CA06D60EB7@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 Mike Frysinger, In message you wrote: > On Thu, May 5, 2011 at 12:52, Simon Glass wrote: > > +static void auto_load(void) > > +{ > > + char *s = getenv("autoload"); > > const char *s Agreed. > > + if (s != NULL) { > > + if (*s == 'n') { > > + /* > > + * Just use BOOTP to configure system; > > + * Do not use TFTP to load the bootfile. > > + */ > > + NetState = NETLOOP_SUCCES> S; > > + return; > > +#if defined(CONFIG_CMD_NFS) > > + } else if (strcmp(s, "NFS") == 0) { > > + /* > > + * Use NFS to load the bo> otfile. > > + */ > > + NfsStart(); > > + return; > > +#endif > > + } > > + } > > + > > + TftpStart(); > > put the TftpStart into a new else, then there's no need for the inline > "return" ... I disagree here. As is, we save one level of nesting, which is always a good thing. On contrary, the "else" in the CONFIG_CMD_NFS should be dropped as well, i. e. let's make this: + if (s != NULL) { + if (*s == 'n') { + /* + * Just use BOOTP to configure system; + * Do not use TFTP to load the bootfile. + */ + NetState = NETLOOP_SUCCES> S; + return; + } +#if defined(CONFIG_CMD_NFS) + if (strcmp(s, "NFS") == 0) { + /* + * Use NFS to load the bootfile. + */ + NfsStart(); + return; } +#endif + } + + TftpStart(); 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 "We learn from history that we learn nothing from history." - George Bernard Shaw