[U-Boot] [PATCH 2/2] sandbox: Fix warnings in cpu.c and os.c

Simon Glass sjg at chromium.org
Tue Nov 11 20:47:08 CET 2014


This fixes the following two problems:

cppcheck reports:
[arch/sandbox/cpu/start.c:132]: (error) Uninitialized variable: err
[arch/sandbox/cpu/os.c:371]: (error) Memory leak: fname

Signed-off-by: Simon Glass <sjg at chromium.org>
Reported-by: Wolfgang Denk <wd at denx.de>
---

 arch/sandbox/cpu/os.c    | 1 +
 arch/sandbox/cpu/start.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 1c4aa3f..f572cae 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -367,6 +367,7 @@ int os_dirent_ls(const char *dirname, struct os_dirent_node **headp)
 
 done:
 	closedir(dir);
+	free(fname);
 	return ret;
 }
 
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 53a99ae..656bd75 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -130,7 +130,8 @@ static int sandbox_cmdline_cb_memory(struct sandbox_state *state,
 	state->write_ram_buf = true;
 	state->ram_buf_fname = arg;
 
-	if (os_read_ram_buf(arg)) {
+	err = os_read_ram_buf(arg);
+	if (err) {
 		printf("Failed to read RAM buffer\n");
 		return err;
 	}
-- 
2.1.0.rc2.206.gedb03e5



More information about the U-Boot mailing list