From 76d6af0fd310967d8bf08d01cfc1db00e4a0c757 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 25 Nov 2014 15:26:30 -0600 Subject: Fixes for more issues found by cppcheck --- apps/netutils/dhcpd/dhcpd.c | 7 +++++-- apps/netutils/ftpc/ftpc_chmod.c | 3 +-- apps/netutils/ftpc/ftpc_rpwd.c | 4 ++-- apps/netutils/ftpc/ftpc_transfer.c | 7 +++---- apps/netutils/ftpd/ftpd.c | 6 +++--- apps/netutils/thttpd/cgi-src/ssi.c | 4 ++-- apps/netutils/webserver/httpd.c | 7 +++---- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/netutils/dhcpd/dhcpd.c b/apps/netutils/dhcpd/dhcpd.c index 93b061db7..cb58d0a43 100644 --- a/apps/netutils/dhcpd/dhcpd.c +++ b/apps/netutils/dhcpd/dhcpd.c @@ -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 diff --git a/apps/netutils/ftpc/ftpc_chmod.c b/apps/netutils/ftpc/ftpc_chmod.c index e5cd48b46..ea84c66de 100644 --- a/apps/netutils/ftpc/ftpc_chmod.c +++ b/apps/netutils/ftpc/ftpc_chmod.c @@ -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" */ diff --git a/apps/netutils/ftpc/ftpc_rpwd.c b/apps/netutils/ftpc/ftpc_rpwd.c index 91dd1504f..1f87f5f14 100644 --- a/apps/netutils/ftpc/ftpc_rpwd.c +++ b/apps/netutils/ftpc/ftpc_rpwd.c @@ -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; } diff --git a/apps/netutils/ftpc/ftpc_transfer.c b/apps/netutils/ftpc/ftpc_transfer.c index e26d7e87b..8dbb2d0ad 100644 --- a/apps/netutils/ftpc/ftpc_transfer.c +++ b/apps/netutils/ftpc/ftpc_transfer.c @@ -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; diff --git a/apps/netutils/ftpd/ftpd.c b/apps/netutils/ftpd/ftpd.c index 51e1b35b1..d3d523ae4 100644 --- a/apps/netutils/ftpd/ftpd.c +++ b/apps/netutils/ftpd/ftpd.c @@ -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 */ diff --git a/apps/netutils/thttpd/cgi-src/ssi.c b/apps/netutils/thttpd/cgi-src/ssi.c index 12d59d271..849067756 100644 --- a/apps/netutils/thttpd/cgi-src/ssi.c +++ b/apps/netutils/thttpd/cgi-src/ssi.c @@ -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)); } diff --git a/apps/netutils/webserver/httpd.c b/apps/netutils/webserver/httpd.c index 05bf50a1b..f177a51ea 100644 --- a/apps/netutils/webserver/httpd.c +++ b/apps/netutils/webserver/httpd.c @@ -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 -- cgit v1.2.3