[U-Boot] [PATCH] MatrixVision common code: use getenv_f instead of snprintf.

Signed-off-by: Andre Schwarz andre.schwarz@matrix-vision.de --- board/matrix_vision/common/mv_common.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/board/matrix_vision/common/mv_common.c b/board/matrix_vision/common/mv_common.c index 0afc535..742a90a 100644 --- a/board/matrix_vision/common/mv_common.c +++ b/board/matrix_vision/common/mv_common.c @@ -32,7 +32,7 @@ DECLARE_GLOBAL_DATA_PTR; static char* entries_to_keep[] = { "serial#", "ethaddr", "eth1addr", "model_info", "sensor_cnt", "fpgadatasize", "ddr_size", "use_dhcp", "use_static_ipaddr", - "static_ipaddr", "static_netmask", "static_gateway", + "static_ipaddr", "static_netmask", "static_gateway", "boot_sqfs", "syslog", "watchdog", "netboot", "evo8serialnumber" };
#define MV_MAX_ENV_ENTRY_LENGTH 64 @@ -41,28 +41,27 @@ static char* entries_to_keep[] = { void mv_reset_environment(void) { int i; - char *s[MV_KEEP_ENTRIES]; char entries[MV_KEEP_ENTRIES][MV_MAX_ENV_ENTRY_LENGTH];
printf("\n*** RESET ENVIRONMENT ***\n");
memset(entries, 0, MV_KEEP_ENTRIES * MV_MAX_ENV_ENTRY_LENGTH); + for (i = 0; i < MV_KEEP_ENTRIES; i++) { - s[i] = getenv(entries_to_keep[i]); - if (s[i]) { - printf("save '%s' : %s\n", entries_to_keep[i], s[i]); - strncpy(entries[i], s[i], MV_MAX_ENV_ENTRY_LENGTH); - } + if (getenv_f(entries_to_keep[i], entries[i], + MV_MAX_ENV_ENTRY_LENGTH) <= 0) + memset(entries[i], 0, MV_MAX_ENV_ENTRY_LENGTH); + else + printf("save '%s' : %s\n", entries_to_keep[i], + entries[i]); }
gd->env_valid = 0; env_relocate();
for (i = 0; i < MV_KEEP_ENTRIES; i++) { - if (s[i]) { - printf("restore '%s' : %s\n", entries_to_keep[i], s[i]); - setenv(entries_to_keep[i], s[i]); - } + printf("restore '%s' : %s\n", entries_to_keep[i], entries[i]); + setenv(entries_to_keep[i], entries[i]); }
saveenv(); @@ -70,7 +69,8 @@ void mv_reset_environment(void)
int mv_load_fpga(void) { - int result; + int result = -1; +#ifdef CONFIG_FPGA size_t data_size = 0; void *fpga_data = NULL; char *datastr = getenv("fpgadata"); @@ -92,6 +92,7 @@ int mv_load_fpga(void) }
result = fpga_load(0, fpga_data, data_size); +#endif if (!result) show_boot_progress(0);

Dear Andre Schwarz,
In message 1302785522-14393-1-git-send-email-andre.schwarz@matrix-vision.de you wrote:
Signed-off-by: Andre Schwarz andre.schwarz@matrix-vision.de
It appears this commit contains some unrelated changes?
- "static_ipaddr", "static_netmask", "static_gateway",
- "static_ipaddr", "static_netmask", "static_gateway", "boot_sqfs",
...like this.
int mv_load_fpga(void) {
- int result;
- int result = -1;
+#ifdef CONFIG_FPGA size_t data_size = 0; void *fpga_data = NULL; char *datastr = getenv("fpgadata"); @@ -92,6 +92,7 @@ int mv_load_fpga(void) }
result = fpga_load(0, fpga_data, data_size); +#endif
... or that.
Please split into orthogonal changes.
Best regards,
Wolfgang Denk
participants (2)
-
Andre Schwarz
-
Wolfgang Denk