[U-Boot] [PATCH v3 18/21] Remove unused variable warnings in cmd_mem, cmd_nvedit

Simon Glass sjg at chromium.org
Tue Sep 27 02:10:52 CEST 2011


There are a few variables set but not used - this marks these as unused
for the compiler.

Merek's GCC4.6 patch series fixes these so this patch does not need to be
applied if you have these:
- GCC4.6: Squash warning in cmd_mem.c
- GCC4.6: Squash warning in cmd_nvedit.c

Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Try to avoid needing __attribute__((unused)) by assigning to an existing var

Changes in v3:
- Remove variable assignment and rely on 'volatile' to perform the read
- Add note about Merek's patch set

 common/cmd_mem.c    |    8 ++++----
 common/cmd_nvedit.c |    3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 4daa1b3..e84cc4e 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -471,7 +471,7 @@ int do_mem_base (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-	ulong	addr, length, i, junk;
+	ulong	addr, length, i;
 	int	size;
 	volatile uint	*longp;
 	volatile ushort *shortp;
@@ -518,7 +518,7 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			longp = (uint *)addr;
 			i = length;
 			while (i-- > 0)
-				junk = *longp++;
+				*longp++;
 		}
 	}
 	if (size == 2) {
@@ -526,14 +526,14 @@ int do_mem_loop (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 			shortp = (ushort *)addr;
 			i = length;
 			while (i-- > 0)
-				junk = *shortp++;
+				*shortp++;
 		}
 	}
 	for (;;) {
 		cp = (u_char *)addr;
 		i = length;
 		while (i-- > 0)
-			junk = *cp++;
+			*cp++;
 	}
 }
 
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index e8b116d..101bc49 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -460,7 +460,6 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	char buffer[CONFIG_SYS_CBSIZE];
 	char *init_val;
-	int len;
 
 	if (argc < 2)
 		return cmd_usage(cmdtp);
@@ -468,7 +467,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	/* Set read buffer to initial value or empty sting */
 	init_val = getenv(argv[1]);
 	if (init_val)
-		len = sprintf(buffer, "%s", init_val);
+		sprintf(buffer, "%s", init_val);
 	else
 		buffer[0] = '\0';
 
-- 
1.7.3.1



More information about the U-Boot mailing list