From patchwork Thu Apr 14 12:52:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Schwarz X-Patchwork-Id: 91226 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 9A113B6F5F for ; Thu, 14 Apr 2011 22:52:16 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DBB9F28363; Thu, 14 Apr 2011 14:52:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rtcLIGIV-Czy; Thu, 14 Apr 2011 14:52:14 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7D74328368; Thu, 14 Apr 2011 14:52:12 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CE4B528368 for ; Thu, 14 Apr 2011 14:52:09 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kZkBbS6xJtul for ; Thu, 14 Apr 2011 14:52:09 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail2.matrix-vision.com (mail2.matrix-vision.com [85.214.244.251]) by theia.denx.de (Postfix) with ESMTPS id 0804828363 for ; Thu, 14 Apr 2011 14:52:07 +0200 (CEST) Received: from mail2.matrix-vision.com (localhost [127.0.0.1]) by mail2.matrix-vision.com (Postfix) with ESMTP id 0F32A405FB; Thu, 14 Apr 2011 14:52:05 +0200 (CEST) Received: from erinome (g2.matrix-vision.com [80.152.136.245]) by mail2.matrix-vision.com (Postfix) with ESMTPA id C79CD3F64C; Thu, 14 Apr 2011 14:52:04 +0200 (CEST) Received: from erinome (localhost [127.0.0.1]) by erinome (Postfix) with ESMTP id 5734B6F8A; Thu, 14 Apr 2011 14:52:04 +0200 (CEST) Received: by erinome (Postfix, from userid 108) id 45B4B6F9C; Thu, 14 Apr 2011 14:52:04 +0200 (CEST) Received: from localhost.localdomain (host65-223.intern.matrix-vision.de [192.168.65.223]) by erinome (Postfix) with ESMTPA id 3557F6F8A; Thu, 14 Apr 2011 14:52:04 +0200 (CEST) From: Andre Schwarz To: U-Boot@lists.denx.de Date: Thu, 14 Apr 2011 14:52:02 +0200 Message-Id: <1302785522-14393-1-git-send-email-andre.schwarz@matrix-vision.de> X-Mailer: git-send-email 1.7.0.4 X-AV-Checked: ClamAV using ClamSMTP (erinome) X-AV-Checked: ClamAV using ClamSMTP (mail2) Subject: [U-Boot] [PATCH] MatrixVision common code: use getenv_f instead of snprintf. X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Andre Schwarz --- 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);