Fixes for more issues found by cppcheck
This commit is contained in:
parent
846dd0e45d
commit
55bfbed33f
@ -478,8 +478,10 @@ static inline bool dhcpd_parseoptions(void)
|
||||
{
|
||||
uint32_t tmp;
|
||||
uint8_t *ptr;
|
||||
#ifndef CONFIG_NET_DHCP_LIGHT
|
||||
uint8_t overloaded;
|
||||
uint8_t currfield;
|
||||
#endif
|
||||
int optlen = 0;
|
||||
int remaining;
|
||||
|
||||
@ -498,8 +500,10 @@ static inline bool dhcpd_parseoptions(void)
|
||||
|
||||
ptr += 4;
|
||||
remaining = DHCPD_OPTIONS_SIZE - 4;
|
||||
#ifndef CONFIG_NET_DHCP_LIGHT
|
||||
overloaded = DHCPD_OPTION_FIELD;
|
||||
currfield = DHCPD_OPTION_FIELD;
|
||||
#endif
|
||||
|
||||
/* Set all options to the default value */
|
||||
|
||||
@ -637,8 +641,7 @@ static inline bool dhcpd_verifyreqip(void)
|
||||
|
||||
/* Verify that the requested IP address is within the supported lease range */
|
||||
|
||||
if (g_state.ds_optreqip > 0 &&
|
||||
g_state.ds_optreqip >= CONFIG_NETUTILS_DHCPD_STARTIP &&
|
||||
if (g_state.ds_optreqip >= CONFIG_NETUTILS_DHCPD_STARTIP &&
|
||||
g_state.ds_optreqip <= CONFIG_NETUTILS_DHCP_OPTION_ENDIP)
|
||||
{
|
||||
/* And verify that the lease has not already been taken or offered
|
||||
|
@ -79,13 +79,12 @@
|
||||
int ftpc_chmod(SESSION handle, FAR const char *path, FAR const char *mode)
|
||||
{
|
||||
FAR struct ftpc_session_s *session = (FAR struct ftpc_session_s *)handle;
|
||||
int ret;
|
||||
|
||||
/* Does the server support the size CHMOD command? */
|
||||
|
||||
if (FTPC_HAS_CHMOD(session))
|
||||
{
|
||||
ret = ftpc_cmd(session, "SITE CHMOD %s %s", path, mode);
|
||||
(void)ftpc_cmd(session, "SITE CHMOD %s %s", path, mode);
|
||||
|
||||
/* Check for "502 Command not implemented" */
|
||||
|
||||
|
@ -87,11 +87,10 @@ FAR char *ftpc_rpwd(SESSION handle)
|
||||
FAR char *pwd;
|
||||
FAR char *ptr;
|
||||
int len;
|
||||
int ret;
|
||||
|
||||
/* Send the PWD command */
|
||||
|
||||
ret = ftpc_cmd(session, "PWD");
|
||||
(void)ftpc_cmd(session, "PWD");
|
||||
|
||||
/* Response is like: 257 "/home/gnutt" (from vsftpd).
|
||||
*
|
||||
@ -147,5 +146,6 @@ FAR char *ftpc_rpwd(SESSION handle)
|
||||
*ptr = '/';
|
||||
}
|
||||
}
|
||||
|
||||
return pwd;
|
||||
}
|
||||
|
@ -171,7 +171,6 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
||||
FAR const char *curdir)
|
||||
{
|
||||
FAR char *ptr = NULL;
|
||||
int ret = OK;
|
||||
|
||||
/* If no relative path was provide, then use the current working directory */
|
||||
|
||||
@ -195,7 +194,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
||||
|
||||
else if (relpath[1] == '/')
|
||||
{
|
||||
ret = asprintf(&ptr, "%s%s", homedir, &relpath[1]);
|
||||
(void)asprintf(&ptr, "%s%s", homedir, &relpath[1]);
|
||||
}
|
||||
|
||||
/* Hmmm... this pretty much guaranteed to fail */
|
||||
@ -212,7 +211,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
||||
|
||||
else if (strncmp(relpath, "./", 2) == 0)
|
||||
{
|
||||
ret = asprintf(&ptr, "%s%s", curdir, relpath+1);
|
||||
(void)asprintf(&ptr, "%s%s", curdir, relpath+1);
|
||||
}
|
||||
|
||||
/* Check for an absolute path */
|
||||
@ -226,7 +225,7 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s *session,
|
||||
|
||||
else
|
||||
{
|
||||
ret = asprintf(&ptr, "%s/%s", curdir, relpath);
|
||||
(void)asprintf(&ptr, "%s/%s", curdir, relpath);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
@ -2400,7 +2400,7 @@ static int ftpd_list(FAR struct ftpd_session_s *session, unsigned int opton)
|
||||
free(abspath);
|
||||
}
|
||||
|
||||
return OK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -2768,7 +2768,7 @@ static int ftpd_command_eprt(FAR struct ftpd_session_s *session)
|
||||
left = 0;
|
||||
right = strlen(session->param);
|
||||
|
||||
if (right <= 0)
|
||||
if (right < 1)
|
||||
{
|
||||
/* no message ? */
|
||||
|
||||
@ -2789,7 +2789,7 @@ static int ftpd_command_eprt(FAR struct ftpd_session_s *session)
|
||||
left++;
|
||||
}
|
||||
|
||||
if (right <= 0 || left > right)
|
||||
if (right < 1 || left > right)
|
||||
{
|
||||
/* Invalid format */
|
||||
|
||||
|
@ -378,11 +378,11 @@ static void show_size(off_t size)
|
||||
{
|
||||
(void)printf("%ld", (long)size);
|
||||
}
|
||||
else if (size < 1024)
|
||||
else if (size < 1024 * 1024)
|
||||
{
|
||||
(void)printf("%ldK", (long)size / 1024L);
|
||||
}
|
||||
else if (size < 1024 * 1024)
|
||||
else if (size < 1024 * 1024 * 1024)
|
||||
{
|
||||
(void)printf("%ldM", (long)size / (1024L * 1024L));
|
||||
}
|
||||
|
@ -736,8 +736,7 @@ static inline int httpd_parse(struct httpd_state *pstate)
|
||||
static void *httpd_handler(void *arg)
|
||||
{
|
||||
struct httpd_state *pstate = (struct httpd_state *)malloc(sizeof(struct httpd_state));
|
||||
int sockfd = (int)arg;
|
||||
int ret = ERROR;
|
||||
int sockfd = (int)arg;
|
||||
|
||||
nvdbg("[%d] Started\n", sockfd);
|
||||
|
||||
@ -762,11 +761,11 @@ static void *httpd_handler(void *arg)
|
||||
status = httpd_parse(pstate);
|
||||
if (status >= 400)
|
||||
{
|
||||
ret = httpd_senderror(pstate, status);
|
||||
(void)httpd_senderror(pstate, status);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = httpd_sendfile(pstate);
|
||||
(void) httpd_sendfile(pstate);
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NETUTILS_HTTPD_KEEPALIVE_DISABLE
|
||||
|
Loading…
Reference in New Issue
Block a user