apps/nshlib: fix unreachable code about i++
Report by the tool coverity Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
parent
385603666b
commit
467de8ca83
@ -70,7 +70,6 @@ int nsh_session(FAR struct console_stdio_s *pstate,
|
||||
{
|
||||
FAR struct nsh_vtbl_s *vtbl;
|
||||
int ret = EXIT_FAILURE;
|
||||
int i;
|
||||
|
||||
DEBUGASSERT(pstate);
|
||||
vtbl = &pstate->cn_vtbl;
|
||||
@ -116,45 +115,40 @@ int nsh_session(FAR struct console_stdio_s *pstate,
|
||||
|
||||
/* Process the command line option */
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if (strcmp(argv[1], "-h") == 0)
|
||||
{
|
||||
if (strcmp(argv[i], "-h") == 0)
|
||||
{
|
||||
nsh_output(vtbl, "Usage: %s [<script-path>|-c <command>]\n",
|
||||
argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else if (strcmp(argv[i], "-c") == 0)
|
||||
{
|
||||
/* Process the inline command */
|
||||
nsh_output(vtbl, "Usage: %s [<script-path>|-c <command>]\n",
|
||||
argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else if (strcmp(argv[1], "-c") == 0)
|
||||
{
|
||||
/* Process the inline command */
|
||||
|
||||
if (i + 1 < argc)
|
||||
{
|
||||
return nsh_parse(vtbl, argv[i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsh_error(vtbl, g_fmtargrequired, argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else if (argv[i][0] != '-')
|
||||
if (argc > 2)
|
||||
{
|
||||
break;
|
||||
return nsh_parse(vtbl, argv[2]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
nsh_error(vtbl, g_fmtargrequired, argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else if (argv[1][0] == '-')
|
||||
{
|
||||
/* Unknown option */
|
||||
|
||||
nsh_error(vtbl, g_fmtsyntax, argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (i < argc)
|
||||
if (argc > 1)
|
||||
{
|
||||
#ifndef CONFIG_NSH_DISABLESCRIPT
|
||||
/* Execute the shell script */
|
||||
|
||||
return nsh_script(vtbl, argv[0], argv[i]);
|
||||
return nsh_script(vtbl, argv[0], argv[1]);
|
||||
#else
|
||||
return EXIT_FAILURE;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user