1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-30 23:11:32 +02:00

common: command: trivial coding style fixes

- Do not insert a whitespace between a function name and
   an open paranthesis
 - Fix comment style
 - Do not split an error message into multiple lines
   even if it exceeds 80 columns
 - Do not split "for" statement where it fits in 80 columns
 - Do not use assignment in if condition

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Masahiro Yamada
2014-10-23 17:27:30 +09:00
committed by Tom Rini
parent 5699ea6d0e
commit 616e2162a5

View File

@@ -18,8 +18,8 @@
* for long help messages * for long help messages
*/ */
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int int _do_help(cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t *cmdtp, int flag,
flag, int argc, char * const argv[]) int argc, char * const argv[])
{ {
int i; int i;
int rcode = 0; int rcode = 0;
@@ -69,22 +69,19 @@ int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
* command help (long version) * command help (long version)
*/ */
for (i = 1; i < argc; ++i) { for (i = 1; i < argc; ++i) {
if ((cmdtp = find_cmd_tbl (argv[i], cmd_start, cmd_items )) != NULL) { cmdtp = find_cmd_tbl(argv[i], cmd_start, cmd_items);
if (cmdtp != NULL) {
rcode |= cmd_usage(cmdtp); rcode |= cmd_usage(cmdtp);
} else { } else {
printf ("Unknown command '%s' - try 'help'" printf("Unknown command '%s' - try 'help' without arguments for list of all known commands\n\n",
" without arguments for list of all" argv[i]);
" known commands\n\n", argv[i]
);
rcode = 1; rcode = 1;
} }
} }
return rcode; return rcode;
} }
/*************************************************************************** /* find command table entry for a command */
* find command table entry for a command
*/
cmd_tbl_t *find_cmd_tbl(const char *cmd, cmd_tbl_t *table, int table_len) cmd_tbl_t *find_cmd_tbl(const char *cmd, cmd_tbl_t *table, int table_len)
{ {
cmd_tbl_t *cmdtp; cmd_tbl_t *cmdtp;
@@ -101,9 +98,7 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len)
*/ */
len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd); len = ((p = strchr(cmd, '.')) == NULL) ? strlen (cmd) : (p - cmd);
for (cmdtp = table; for (cmdtp = table; cmdtp != table + table_len; cmdtp++) {
cmdtp != table + table_len;
cmdtp++) {
if (strncmp(cmd, cmdtp->name, len) == 0) { if (strncmp(cmd, cmdtp->name, len) == 0) {
if (len == strlen(cmdtp->name)) if (len == strlen(cmdtp->name))
return cmdtp; /* full match */ return cmdtp; /* full match */
@@ -194,7 +189,7 @@ static int complete_cmdv(int argc, char * const argv[], char last_char, int maxv
} }
/* more than one arg or one but the start of the next */ /* more than one arg or one but the start of the next */
if (argc > 1 || (last_char == '\0' || isblank(last_char))) { if (argc > 1 || last_char == '\0' || isblank(last_char)) {
cmdtp = find_cmd(argv[0]); cmdtp = find_cmd(argv[0]);
if (cmdtp == NULL || cmdtp->complete == NULL) { if (cmdtp == NULL || cmdtp->complete == NULL) {
cmdv[0] = NULL; cmdv[0] = NULL;
@@ -345,7 +340,8 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp)
argc = make_argv(tmp_buf, sizeof(argv)/sizeof(argv[0]), argv); argc = make_argv(tmp_buf, sizeof(argv)/sizeof(argv[0]), argv);
/* do the completion and return the possible completions */ /* do the completion and return the possible completions */
i = complete_cmdv(argc, argv, last_char, sizeof(cmdv)/sizeof(cmdv[0]), cmdv); i = complete_cmdv(argc, argv, last_char,
sizeof(cmdv) / sizeof(cmdv[0]), cmdv);
/* no match; bell and out */ /* no match; bell and out */
if (i == 0) { if (i == 0) {