From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Thu, 04 Dec 2008 07:46:59 -0500 Subject: [U-Boot] [PATCH] common: nvedit to protect additional ethernet addresses Part 1/1 In-Reply-To: <4937cd00.hX/ek4tggr3wX3a8%stefan.althoefer@web.de> References: <4937cd00.hX/ek4tggr3wX3a8%stefan.althoefer@web.de> Message-ID: <4937D143.1030902@ge.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de stefan.althoefer at web.de wrote: > [PATCH] common: nvedit to protect additional ethernet addresses > > This patch adds "ethaddr1" and "ethaddr2" to the protected > environment variables that can only be written once. > > ---- > The patch is against "latest" u-boot git-repository > > Please be patient if style of submission or patches are > offending. > > Signed-off-by: stefan.althoefer at web.de (as at janz.de) > ---- > > diff -uprN u-boot-orig//common/cmd_nvedit.c u-boot/common/cmd_nvedit.c > --- u-boot-orig//common/cmd_nvedit.c 2008-12-02 17:25:31.000000000 +0100 > +++ u-boot/common/cmd_nvedit.c 2008-12-02 22:59:36.000000000 +0100 > @@ -188,6 +188,8 @@ int _do_setenv (int flag, int argc, char > #else > (strcmp (name, "serial#") == 0) || > #endif > + (strcmp (name, "ethaddr1") == 0) || > + (strcmp (name, "ethaddr2") == 0) || > ((strcmp (name, "ethaddr") == 0) > #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) > && (strcmp ((char *)env_get_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0) Would it be better to use "strncmp (name, "ethaddr", 7)" instead of adding all possible enumerations of ethaddr[0-9]*? Using strncmp() will match any ethaddr.* variable (a wider net than ethaddr[0-9]*, but given our limited environment it shouldn't matter). gvb