Fixing coding style issues for rest of nshlib directory - except for the false +ve nsh_timcmds.c

This commit is contained in:
Subhra Sankha Sarkar
2020-11-02 17:00:26 +05:30
committed by Alin Jerpelea
parent 0f4ad7dc5f
commit 3b884cfb87
5 changed files with 99 additions and 93 deletions

View File

@@ -355,6 +355,7 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
} }
} }
#endif #endif
rtrndx = 2; rtrndx = 2;
} }
else else

View File

@@ -341,7 +341,8 @@ int cmd_reboot(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
#if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN) #if defined(CONFIG_RPTUN) && !defined(CONFIG_NSH_DISABLE_RPTUN)
int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
int fd, cmd; int fd;
int cmd;
if (argc < 3) if (argc < 3)
{ {

View File

@@ -70,7 +70,8 @@
* Name: nsh_telnetecho * Name: nsh_telnetecho
****************************************************************************/ ****************************************************************************/
static void nsh_telnetecho(FAR struct console_stdio_s *pstate, uint8_t is_use) static void nsh_telnetecho(FAR struct console_stdio_s *pstate,
uint8_t is_use)
{ {
uint8_t optbuf[4]; uint8_t optbuf[4];
optbuf[0] = TELNET_IAC; optbuf[0] = TELNET_IAC;
@@ -193,7 +194,8 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
fflush(pstate->cn_outstream); fflush(pstate->cn_outstream);
username[0] = '\0'; username[0] = '\0';
if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN, INSTREAM(pstate)) != NULL) if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN,
INSTREAM(pstate)) != NULL)
{ {
/* Parse out the username */ /* Parse out the username */
@@ -207,7 +209,8 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
nsh_telnetecho(pstate, TELNET_NOTUSE_ECHO); nsh_telnetecho(pstate, TELNET_NOTUSE_ECHO);
password[0] = '\0'; password[0] = '\0';
if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN, INSTREAM(pstate)) != NULL) if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN,
INSTREAM(pstate)) != NULL)
{ {
/* Parse out the password */ /* Parse out the password */
@@ -218,7 +221,8 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
#if defined(CONFIG_NSH_LOGIN_PASSWD) #if defined(CONFIG_NSH_LOGIN_PASSWD)
if (PASSWORD_VERIFY_MATCH(passwd_verify(username, password))) if (PASSWORD_VERIFY_MATCH(passwd_verify(username, password)))
#elif defined(CONFIG_NSH_LOGIN_PLATFORM) #elif defined(CONFIG_NSH_LOGIN_PLATFORM)
if (PASSWORD_VERIFY_MATCH(platform_user_verify(username, password))) if (PASSWORD_VERIFY_MATCH(platform_user_verify(username,
password)))
#elif defined(CONFIG_NSH_LOGIN_FIXED) #elif defined(CONFIG_NSH_LOGIN_FIXED)
if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 && if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0) strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0)

View File

@@ -285,7 +285,7 @@ static inline int unaryexpression(FAR struct nsh_vtbl_s *vtbl, char **argv)
{ {
/* Return true if the file is readable */ /* Return true if the file is readable */
return (buf.st_mode & (S_IRUSR|S_IRGRP|S_IROTH)) != 0 ? return (buf.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) != 0 ?
TEST_TRUE : TEST_FALSE; TEST_TRUE : TEST_FALSE;
} }
@@ -304,7 +304,7 @@ static inline int unaryexpression(FAR struct nsh_vtbl_s *vtbl, char **argv)
{ {
/* Return true if the file is write-able */ /* Return true if the file is write-able */
return (buf.st_mode & (S_IWUSR|S_IWGRP|S_IWOTH)) != 0 ? return (buf.st_mode & (S_IWUSR | S_IWGRP | S_IWOTH)) != 0 ?
TEST_TRUE : TEST_FALSE; TEST_TRUE : TEST_FALSE;
} }
@@ -331,7 +331,7 @@ static int expression(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
goto errout_syntax; goto errout_syntax;
} }
return expression(vtbl, argc-1, &argv[1]) == TEST_TRUE ? return expression(vtbl, argc - 1, &argv[1]) == TEST_TRUE ?
TEST_FALSE : TEST_TRUE; TEST_FALSE : TEST_TRUE;
} }
@@ -383,7 +383,7 @@ static int expression(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
else else
{ {
i++; i++;
return expression(vtbl, argc-i, &argv[i]); return expression(vtbl, argc - i, &argv[i]);
} }
} }
@@ -398,7 +398,7 @@ static int expression(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
else else
{ {
i++; i++;
return expression(vtbl, argc-i, &argv[i]); return expression(vtbl, argc - i, &argv[i]);
} }
} }
else else
@@ -424,7 +424,7 @@ errout_syntax:
int cmd_test(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) int cmd_test(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
{ {
return expression(vtbl, argc-1, &argv[1]); return expression(vtbl, argc - 1, &argv[1]);
} }
/**************************************************************************** /****************************************************************************

View File

@@ -204,7 +204,7 @@ int nsh_removevar(FAR struct console_stdio_s *pstate, FAR char *pair)
* Name: nsh_getvar * Name: nsh_getvar
****************************************************************************/ ****************************************************************************/
FAR char *nsh_getvar(FAR struct nsh_vtbl_s *vtbl,FAR const char *name) FAR char *nsh_getvar(FAR struct nsh_vtbl_s *vtbl, FAR const char *name)
{ {
FAR struct console_stdio_s *pstate = (FAR struct console_stdio_s *)vtbl; FAR struct console_stdio_s *pstate = (FAR struct console_stdio_s *)vtbl;
FAR char *pair; FAR char *pair;
@@ -258,8 +258,8 @@ int nsh_setvar(FAR struct nsh_vtbl_s *vtbl, FAR const char *name,
nsh_removevar(pstate, pair); nsh_removevar(pstate, pair);
} }
/* Get the size of the new name=value string. The +2 is for the '=' and for /* Get the size of the new name=value string. The +2 is for the '=' and
* null terminator * for null terminator
*/ */
varlen = strlen(name) + strlen(value) + 2; varlen = strlen(name) + strlen(value) + 2;