Fixing coding style issues for rest of nshlib directory - except for the false +ve nsh_timcmds.c
This commit is contained in:
parent
0f4ad7dc5f
commit
3b884cfb87
@ -60,36 +60,36 @@
|
||||
|
||||
static int slash_notation(FAR char *arg)
|
||||
{
|
||||
FAR char *sptr;
|
||||
FAR char *ptr;
|
||||
FAR char *sptr;
|
||||
FAR char *ptr;
|
||||
|
||||
/* If an address contains a /, then the netmask is imply by the following
|
||||
* numeric value.
|
||||
*/
|
||||
/* If an address contains a /, then the netmask is imply by the following
|
||||
* numeric value.
|
||||
*/
|
||||
|
||||
sptr = strchr(arg, '/');
|
||||
if (sptr != NULL)
|
||||
{
|
||||
/* Make sure that everything following the slash is a decimal digit. */
|
||||
sptr = strchr(arg, '/');
|
||||
if (sptr != NULL)
|
||||
{
|
||||
/* Make sure that everything following the slash is a decimal digit. */
|
||||
|
||||
ptr = sptr + 1;
|
||||
while (isdigit(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
ptr = sptr + 1;
|
||||
while (isdigit(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
|
||||
/* There should be nothing be digits after the slash and up to the
|
||||
* NULL terminator.
|
||||
*/
|
||||
/* There should be nothing be digits after the slash and up to the
|
||||
* NULL terminator.
|
||||
*/
|
||||
|
||||
if (*ptr == '\0')
|
||||
{
|
||||
*sptr++ = '\0';
|
||||
return atoi(sptr);
|
||||
}
|
||||
}
|
||||
if (*ptr == '\0')
|
||||
{
|
||||
*sptr++ = '\0';
|
||||
return atoi(sptr);
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -191,30 +191,30 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
if (family == PF_INET)
|
||||
{
|
||||
ret = netlib_set_dripv4addr(argv[3], &inaddr.ipv4);
|
||||
if (ret != 0)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0]);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
if (family == PF_INET)
|
||||
{
|
||||
ret = netlib_set_dripv4addr(argv[3], &inaddr.ipv4);
|
||||
if (ret != 0)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0]);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (family == PF_INET6)
|
||||
{
|
||||
ret = netlib_set_dripv6addr(argv[3], &inaddr.ipv6);
|
||||
if (ret != 0)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0]);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
if (family == PF_INET6)
|
||||
{
|
||||
ret = netlib_set_dripv6addr(argv[3], &inaddr.ipv6);
|
||||
if (ret != 0)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0]);
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
return OK;
|
||||
}
|
||||
|
||||
/* Check if slash notation is used with the target address */
|
||||
@ -291,7 +291,7 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert the netmask IP address string into its binary form */
|
||||
/* Convert the netmask IP address string into its binary form */
|
||||
|
||||
if (shift >= 0)
|
||||
{
|
||||
@ -355,6 +355,7 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
rtrndx = 2;
|
||||
}
|
||||
else
|
||||
@ -369,7 +370,7 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
|
||||
rtrndx = 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Format the netmask sockaddr instance */
|
||||
|
||||
@ -396,7 +397,7 @@ int cmd_addroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert the router IP address string into its binary form */
|
||||
/* Convert the router IP address string into its binary form */
|
||||
|
||||
ret = inet_pton(family, argv[rtrndx], &inaddr);
|
||||
if (ret != 1)
|
||||
@ -571,7 +572,7 @@ int cmd_delroute(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Convert the netmask IP address string into its binary form */
|
||||
/* Convert the netmask IP address string into its binary form */
|
||||
|
||||
if (shift >= 0)
|
||||
{
|
||||
|
@ -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)
|
||||
int cmd_rptun(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
int fd, cmd;
|
||||
int fd;
|
||||
int cmd;
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
|
@ -70,7 +70,8 @@
|
||||
* 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];
|
||||
optbuf[0] = TELNET_IAC;
|
||||
@ -193,7 +194,8 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
||||
fflush(pstate->cn_outstream);
|
||||
|
||||
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 */
|
||||
|
||||
@ -207,7 +209,8 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
||||
nsh_telnetecho(pstate, TELNET_NOTUSE_ECHO);
|
||||
|
||||
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 */
|
||||
|
||||
@ -218,7 +221,8 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
|
||||
#if defined(CONFIG_NSH_LOGIN_PASSWD)
|
||||
if (PASSWORD_VERIFY_MATCH(passwd_verify(username, password)))
|
||||
#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)
|
||||
if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
|
||||
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0)
|
||||
|
@ -219,7 +219,7 @@ static inline int unaryexpression(FAR struct nsh_vtbl_s *vtbl, char **argv)
|
||||
fullpath = nsh_getfullpath(vtbl, argv[1]);
|
||||
if (!fullpath)
|
||||
{
|
||||
return TEST_FALSE;
|
||||
return TEST_FALSE;
|
||||
}
|
||||
|
||||
ret = stat(fullpath, &buf);
|
||||
@ -227,11 +227,11 @@ static inline int unaryexpression(FAR struct nsh_vtbl_s *vtbl, char **argv)
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
/* The file does not exist (or another error occurred) -- return
|
||||
* FALSE.
|
||||
*/
|
||||
/* The file does not exist (or another error occurred) -- return
|
||||
* FALSE.
|
||||
*/
|
||||
|
||||
return TEST_FALSE;
|
||||
return TEST_FALSE;
|
||||
}
|
||||
|
||||
/* -b 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 (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;
|
||||
}
|
||||
|
||||
@ -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 (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;
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ static int expression(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -374,37 +374,37 @@ static int expression(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
{
|
||||
/* EXPRESSION -a EXPRESSION */
|
||||
|
||||
if (strcmp(argv[i], "-a") == 0)
|
||||
{
|
||||
if (value != TEST_TRUE)
|
||||
{
|
||||
return TEST_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
return expression(vtbl, argc-i, &argv[i]);
|
||||
}
|
||||
}
|
||||
if (strcmp(argv[i], "-a") == 0)
|
||||
{
|
||||
if (value != TEST_TRUE)
|
||||
{
|
||||
return TEST_FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
return expression(vtbl, argc - i, &argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/* EXPRESSION -o EXPRESSION */
|
||||
/* EXPRESSION -o EXPRESSION */
|
||||
|
||||
else if (strcmp(argv[i], "-o") == 0)
|
||||
{
|
||||
if (value == TEST_TRUE)
|
||||
{
|
||||
return TEST_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
return expression(vtbl, argc-i, &argv[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto errout_syntax;
|
||||
}
|
||||
else if (strcmp(argv[i], "-o") == 0)
|
||||
{
|
||||
if (value == TEST_TRUE)
|
||||
{
|
||||
return TEST_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
return expression(vtbl, argc - i, &argv[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
goto errout_syntax;
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -424,7 +424,7 @@ errout_syntax:
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -204,7 +204,7 @@ int nsh_removevar(FAR struct console_stdio_s *pstate, FAR char *pair)
|
||||
* 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 char *pair;
|
||||
@ -258,8 +258,8 @@ int nsh_setvar(FAR struct nsh_vtbl_s *vtbl, FAR const char *name,
|
||||
nsh_removevar(pstate, pair);
|
||||
}
|
||||
|
||||
/* Get the size of the new name=value string. The +2 is for the '=' and for
|
||||
* null terminator
|
||||
/* Get the size of the new name=value string. The +2 is for the '=' and
|
||||
* for null terminator
|
||||
*/
|
||||
|
||||
varlen = strlen(name) + strlen(value) + 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user