From patchwork Sat Apr 16 18:10:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 91492 X-Patchwork-Delegate: macpaul@andestech.com 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 586F6B6FCB for ; Sun, 17 Apr 2011 04:10:41 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ADFF5280D7; Sat, 16 Apr 2011 20:10:38 +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 uppgHGIlj2Fh; Sat, 16 Apr 2011 20:10:38 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5811E280D8; Sat, 16 Apr 2011 20:10:35 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6A562280D8 for ; Sat, 16 Apr 2011 20:10:32 +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 j-0HjaCie357 for ; Sat, 16 Apr 2011 20:10:30 +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 ATCPCS06.andestech.com (59-124-160-117.HINET-IP.hinet.net [59.124.160.117]) by theia.denx.de (Postfix) with ESMTP id 06CAD280D7 for ; Sat, 16 Apr 2011 20:10:26 +0200 (CEST) Received: from app01.andestech.com ([10.0.4.31]) by ATCPCS06.andestech.com with Microsoft SMTPSVC(6.0.3790.4675); Sun, 17 Apr 2011 02:10:23 +0800 From: Macpaul Lin To: u-boot@lists.denx.de Date: Sun, 17 Apr 2011 02:10:19 +0800 Message-Id: <1302977419-3060-1-git-send-email-macpaul@andestech.com> X-Mailer: git-send-email 1.7.3.5 X-OriginalArrivalTime: 16 Apr 2011 18:10:23.0756 (UTC) FILETIME=[8E2D6CC0:01CBFC61] Cc: Macpaul Lin Subject: [U-Boot] [PATCH v2] cmd_nvedit.c: clean up with checkpatch 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 Code clean up of cmd_nvedit.c by using checkpatch.pl. Signed-off-by: Macpaul Lin --- Changes for v2: - Replace the ident characters for #ifdef from space to tab. common/cmd_nvedit.c | 148 +++++++++++++++++++++++++-------------------------- 1 files changed, 73 insertions(+), 75 deletions(-) diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 6d8512a..5fb5a92 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -54,16 +54,16 @@ DECLARE_GLOBAL_DATA_PTR; -#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \ - !defined(CONFIG_ENV_IS_IN_FLASH) && \ - !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ - !defined(CONFIG_ENV_IS_IN_MG_DISK) && \ - !defined(CONFIG_ENV_IS_IN_MMC) && \ - !defined(CONFIG_ENV_IS_IN_NAND) && \ - !defined(CONFIG_ENV_IS_IN_NVRAM) && \ - !defined(CONFIG_ENV_IS_IN_ONENAND) && \ - !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ - !defined(CONFIG_ENV_IS_NOWHERE) +#if !defined(CONFIG_ENV_IS_IN_EEPROM) && \ + !defined(CONFIG_ENV_IS_IN_FLASH) && \ + !defined(CONFIG_ENV_IS_IN_DATAFLASH) && \ + !defined(CONFIG_ENV_IS_IN_MG_DISK) && \ + !defined(CONFIG_ENV_IS_IN_MMC) && \ + !defined(CONFIG_ENV_IS_IN_NAND) && \ + !defined(CONFIG_ENV_IS_IN_NVRAM) && \ + !defined(CONFIG_ENV_IS_IN_ONENAND) && \ + !defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \ + !defined(CONFIG_ENV_IS_NOWHERE) # error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\ SPI_FLASH|MG_DISK|NVRAM|MMC|NOWHERE} #endif @@ -93,7 +93,7 @@ static const unsigned long baudrate_table[] = CONFIG_SYS_BAUDRATE_TABLE; */ static int env_id = 1; -int get_env_id (void) +int get_env_id(void) { return env_id; } @@ -116,7 +116,7 @@ static int env_print(char *name) hsearch_r(e, FIND, &ep, &env_htab); if (ep == NULL) return 0; - len = printf ("%s=%s\n", ep->key, ep->data); + len = printf("%s=%s\n", ep->key, ep->data); return len; } @@ -176,7 +176,7 @@ int _do_env_set (int flag, int argc, char * const argv[]) name = argv[1]; if (strchr(name, '=')) { - printf ("## Error: illegal character '=' in variable name \"%s\"\n", name); + printf("## Error: illegal character '=' in variable name \"%s\"\n", name); return 1; } @@ -189,13 +189,12 @@ int _do_env_set (int flag, int argc, char * const argv[]) hsearch_r(e, FIND, &ep, &env_htab); /* Check for console redirection */ - if (strcmp(name,"stdin") == 0) { + if (strcmp(name, "stdin") == 0) console = stdin; - } else if (strcmp(name,"stdout") == 0) { + else if (strcmp(name, "stdout") == 0) console = stdout; - } else if (strcmp(name,"stderr") == 0) { + else if (strcmp(name, "stderr") == 0) console = stderr; - } if (console != -1) { if (argc < 3) { /* Cannot delete it! */ @@ -209,11 +208,11 @@ int _do_env_set (int flag, int argc, char * const argv[]) return i; #else /* Try assigning specified device */ - if (console_assign (console, argv[2]) < 0) + if (console_assign(console, argv[2]) < 0) return 1; #ifdef CONFIG_SERIAL_MULTI - if (serial_assign (argv[2]) < 0) + if (serial_assign(argv[2]) < 0) return 1; #endif #endif /* CONFIG_CONSOLE_MUX */ @@ -225,28 +224,28 @@ int _do_env_set (int flag, int argc, char * const argv[]) */ if (ep) { /* variable exists */ #ifndef CONFIG_ENV_OVERWRITE - if ((strcmp (name, "serial#") == 0) || - ((strcmp (name, "ethaddr") == 0) + if ((strcmp(name, "serial#") == 0) || + ((strcmp(name, "ethaddr") == 0) #if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR) - && (strcmp (ep->data,MK_STR(CONFIG_ETHADDR)) != 0) + && (strcmp(ep->data, MK_STR(CONFIG_ETHADDR)) != 0) #endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */ ) ) { - printf ("Can't overwrite \"%s\"\n", name); + printf("Can't overwrite \"%s\"\n", name); return 1; } #endif /* * Switch to new baudrate if new baudrate is supported */ - if (strcmp(name,"baudrate") == 0) { + if (strcmp(name, "baudrate") == 0) { int baudrate = simple_strtoul(argv[2], NULL, 10); int i; - for (i=0; ibd->bi_baudrate = baudrate; #endif - serial_setbrg (); + serial_setbrg(); udelay(50000); for (;;) { if (getc() == '\r') - break; + break; } } } @@ -276,14 +275,15 @@ int _do_env_set (int flag, int argc, char * const argv[]) /* * Insert / replace new value */ - for (i=2,len=0; ibi_ip_addr = 0; - for (addr=0, i=0; i<4; ++i) { + for (addr = 0, i = 0; i < 4; ++i) { ulong val = s ? simple_strtoul(s, &e, 10) : 0; addr <<= 8; addr |= (val & 0xFF); @@ -321,20 +321,20 @@ int _do_env_set (int flag, int argc, char * const argv[]) } bd->bi_ip_addr = htonl(addr); return 0; - } else if (strcmp(argv[1],"loadaddr") == 0) { + } else if (strcmp(argv[1], "loadaddr") == 0) { load_addr = simple_strtoul(argv[2], NULL, 16); return 0; } #if defined(CONFIG_CMD_NET) - else if (strcmp(argv[1],"bootfile") == 0) { - copy_filename (BootFile, argv[2], sizeof(BootFile)); + else if (strcmp(argv[1], "bootfile") == 0) { + copy_filename(BootFile, argv[2], sizeof(BootFile)); return 0; } #endif return 0; } -int setenv (char *varname, char *varvalue) +int setenv(char *varname, char *varvalue) { char * const argv[4] = { "setenv", varname, varvalue, NULL }; if ((varvalue == NULL) || (varvalue[0] == '\0')) @@ -343,7 +343,7 @@ int setenv (char *varname, char *varvalue) return _do_env_set(0, 3, argv); } -int do_env_set (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) return cmd_usage(cmdtp); @@ -355,7 +355,7 @@ int do_env_set (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * Prompt for environment variable */ #if defined(CONFIG_CMD_ASKENV) -int do_env_ask ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { extern char console_buffer[CONFIG_SYS_CBSIZE]; char message[CONFIG_SYS_CBSIZE]; @@ -383,10 +383,10 @@ int do_env_ask ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) break; default: /* env_ask envname message1 ... messagen size */ - for (i=2,pos=0; i < argc - 1; i++) { - if (pos) { + for (i = 2, pos = 0; i < argc - 1; i++) { + if (pos) message[pos++] = ' '; - } + strcpy(message+pos, argv[i]); pos += strlen(argv[i]); } @@ -449,7 +449,7 @@ int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) * return address of storage for that variable, * or NULL if not found */ -char *getenv (char *name) +char *getenv(char *name) { if (gd->flags & GD_FLG_ENV_READY) { /* after import into hashtable */ ENTRY e, *ep; @@ -460,7 +460,7 @@ char *getenv (char *name) e.data = NULL; hsearch_r(e, FIND, &ep, &env_htab); - return (ep ? ep->data : NULL); + return ep ? ep->data : NULL; } /* restricted capabilities before import */ @@ -474,23 +474,24 @@ char *getenv (char *name) /* * Look up variable from environment for restricted C runtime env. */ -int getenv_f (char *name, char *buf, unsigned len) +int getenv_f(char *name, char *buf, unsigned len) { int i, nxt; - for (i=0; env_get_char(i) != '\0'; i=nxt+1) { + for (i = 0; env_get_char(i) != '\0'; i = nxt+1) { int val, n; - for (nxt=i; env_get_char(nxt) != '\0'; ++nxt) { - if (nxt >= CONFIG_ENV_SIZE) { - return (-1); - } + for (nxt = i; env_get_char(nxt) != '\0'; ++nxt) { + if (nxt >= CONFIG_ENV_SIZE) + return -1; } - if ((val=envmatch((uchar *)name, i)) < 0) + + val = envmatch((uchar *)name, i); + if (val < 0) continue; /* found; copy out */ - for (n=0; n