Skip to contentSkip to conversation

Patch to setenv() to return status

U-Boot-Users Applied Steven A. Falco 2 participants 2 messages Jun 12, 2008 – Jul 5, 2008

lore
Share & tools
lore
#0 lore raw

Currently, the setenv function does not return an error code. I'd like to propose the following patch, because I want to be able to test for errors in a new BSP I'm writing.

Comments invited.

include/common.h +2 -2
index d0f5704..e2dfc83 100644
@@ -232,9 +232,9 @@ char	*getenv	     (char *);
 int	getenv_r     (char *name, char *buf, unsigned len);
 int	saveenv	     (void);
 #ifdef CONFIG_PPC		/* ARM version to be fixed! */
-void inline setenv   (char *, char *);
+int inline setenv   (char *, char *);
 #else
-void	setenv	     (char *, char *);
+int	setenv	     (char *, char *);
 #ifdef CONFIG_HAS_UID
 void	forceenv     (char *, char *);
 #endif
include/exports.h +1 -1
index d6512cb..6377875 100644
@@ -22,7 +22,7 @@ void vprintf(const char *, va_list);
 void do_reset (void);
 unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
 char *getenv (char *name);
-void setenv (char *varname, char *varvalue);
+int setenv (char *varname, char *varvalue);
 long simple_strtol(const char *cp,char **endp,unsigned int base);
 int strcmp(const char * cs,const char * ct);
 #ifdef CONFIG_HAS_UID
include/asm-arm/u-boot-arm.h +1 -1
index 41e7a8f..4ee5a32 100644
@@ -52,7 +52,7 @@ void	setup_revision_tag (struct tag **params);
 /* To be fixed!							*/
 /* ------------------------------------------------------------ */
 /* common/cmd_nvedit.c */
-void	setenv		(char *, char *);
+int	setenv		(char *, char *);
 
 /* cpu/.../interrupt.c */
 void	reset_timer_masked	(void);
common/cmd_nvedit.c +3 -3
index 9c5d1fc..1ac91ea 100644
@@ -379,13 +380,13 @@ int _do_setenv (int flag, int argc, char *argv[])
 	return 0;
 }
 
-void setenv (char *varname, char *varvalue)
+int setenv (char *varname, char *varvalue)
 {
 	char *argv[4] = { "setenv", varname, varvalue, NULL };
 	if (varvalue == NULL)
-		_do_setenv (0, 2, argv);
+		return _do_setenv (0, 2, argv);
 	else
-		_do_setenv (0, 3, argv);
+		return _do_setenv (0, 3, argv);
 }
 
 #ifdef CONFIG_HAS_UID
#1 lore raw
Quoted 8 lines · In message <[email protected]> you wrote:

Currently, the setenv function does not return an error code. I'd like to propose the following patch, because I want to be able to test for errors in a new BSP I'm writing.

Comments invited.

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
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
"There's only one way to have a happy marriage and as soon as I learn
what it is I'll get married again."                  - Clint Eastwood