ztest: replace shell_fprintf(sh, SHELL_ERROR, ...) with shell_error

Replace `shell_fprintf(sh, SHELL_ERROR, ...)` with
`shell_error(sh, ...)` since it brings the same underlying
action with less typing.

Note: `shell_error` already concatenates `\n` to format strings,
so we remove `\n` from the original code.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This commit is contained in:
Pisit Sawangvonganan 2024-07-31 02:49:46 +07:00 committed by Fabio Baltieri
commit 14c6925596

View file

@ -1285,8 +1285,7 @@ static int cmd_shuffle(const struct shell *sh, size_t argc, char **argv)
case 's':
val = atoi(state->optarg);
if (val < 1) {
shell_fprintf(sh, SHELL_ERROR,
"Invalid number of suite iterations\n");
shell_error(sh, "Invalid number of suite iterations");
return -ENOEXEC;
}
suite_iter = val;
@ -1295,15 +1294,14 @@ static int cmd_shuffle(const struct shell *sh, size_t argc, char **argv)
case 'c':
val = atoi(state->optarg);
if (val < 1) {
shell_fprintf(sh, SHELL_ERROR,
"Invalid number of case iterations\n");
shell_error(sh, "Invalid number of case iterations");
return -ENOEXEC;
}
case_iter = val;
opt_num++;
break;
default:
shell_fprintf(sh, SHELL_ERROR, "Invalid option or option usage: %s\n",
shell_error(sh, "Invalid option or option usage: %s",
argv[opt_index + 1]);
return -ENOEXEC;
}