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:
parent
5699ea6d0e
commit
616e2162a5
|
@ -18,8 +18,8 @@
|
|||
* for long help messages
|
||||
*/
|
||||
|
||||
int _do_help (cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp, int
|
||||
flag, int argc, char * const argv[])
|
||||
int _do_help(cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t *cmdtp, int flag,
|
||||
int argc, char * const argv[])
|
||||
{
|
||||
int i;
|
||||
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)
|
||||
*/
|
||||
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);
|
||||
} else {
|
||||
printf ("Unknown command '%s' - try 'help'"
|
||||
" without arguments for list of all"
|
||||
" known commands\n\n", argv[i]
|
||||
);
|
||||
printf("Unknown command '%s' - try 'help' without arguments for list of all known commands\n\n",
|
||||
argv[i]);
|
||||
rcode = 1;
|
||||
}
|
||||
}
|
||||
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 *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);
|
||||
|
||||
for (cmdtp = table;
|
||||
cmdtp != table + table_len;
|
||||
cmdtp++) {
|
||||
for (cmdtp = table; cmdtp != table + table_len; cmdtp++) {
|
||||
if (strncmp(cmd, cmdtp->name, len) == 0) {
|
||||
if (len == strlen(cmdtp->name))
|
||||
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 */
|
||||
if (argc > 1 || (last_char == '\0' || isblank(last_char))) {
|
||||
if (argc > 1 || last_char == '\0' || isblank(last_char)) {
|
||||
cmdtp = find_cmd(argv[0]);
|
||||
if (cmdtp == NULL || cmdtp->complete == 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);
|
||||
|
||||
/* 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 */
|
||||
if (i == 0) {
|
||||
|
|
Loading…
Reference in New Issue