[PATCH 4/5] common: globvar: let nvvar_remove() report non-existing variable

Enrico Jorns ejo at pengutronix.de
Mon Oct 30 03:34:20 PDT 2017


The former implementation did not allow to detect whether the call to
nvvar_remove() succeeded or failed and always returned 0.

This changes the implementation to return 0 only if a variable with the
given name was found and return ENOENT otherwise.

Signed-off-by: Enrico Jorns <ejo at pengutronix.de>
---
 common/globalvar.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index fdfaf76fae..ee756e5140 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -261,9 +261,11 @@ int nvvar_remove(const char *name)
 
 		unlink(fname);
 		free(fname);
+
+		return 0;
 	}
 
-	return 0;
+	return -ENOENT;
 }
 
 int nvvar_load(void)
-- 
2.11.0




More information about the barebox mailing list