diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-05-11 08:51:21 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-05-11 08:51:21 -0600 |
commit | 1593bc8ff58f1a833872daec312f326b50bffaf5 (patch) | |
tree | 43dc851d981fd518642594c56f46ed1aeb0421ad /apps | |
parent | c8991420a07e91cb7113fed84ec0444999f61f8b (diff) | |
download | px4-nuttx-1593bc8ff58f1a833872daec312f326b50bffaf5.tar.gz px4-nuttx-1593bc8ff58f1a833872daec312f326b50bffaf5.tar.bz2 px4-nuttx-1593bc8ff58f1a833872daec312f326b50bffaf5.zip |
More changes for issues reported by CppCheck
Diffstat (limited to 'apps')
-rw-r--r-- | apps/netutils/codecs/md5.c | 10 | ||||
-rw-r--r-- | apps/netutils/discover/discover.c | 28 | ||||
-rw-r--r-- | apps/netutils/thttpd/libhttpd.c | 56 |
3 files changed, 52 insertions, 42 deletions
diff --git a/apps/netutils/codecs/md5.c b/apps/netutils/codecs/md5.c index eb564973f..0441f4147 100644 --- a/apps/netutils/codecs/md5.c +++ b/apps/netutils/codecs/md5.c @@ -97,15 +97,15 @@ #ifndef CONFIG_ENDIAN_BIG # define byteReverse(buf, len) #else -static void byteReverse(unsigned char *buf, unsigned longs) +static void byteReverse(FAR unsigned char *buf, unsigned longs) { uint32_t t; do { - t = ((uint32_t)buf[3] << 8) | - ((uint32_t)buf[2]) << 16) | - ((uint32_t)buf[1] << 8) | - (uint32_t)buf[0]; + t = ((uint32_t)buf[3] << 24) | + ((uint32_t)buf[2] << 16) | + ((uint32_t)buf[1] << 8) | + (uint32_t)buf[0]; *(uint32_t*)buf = t; buf += 4; diff --git a/apps/netutils/discover/discover.c b/apps/netutils/discover/discover.c index 8e2612dbb..73b783209 100644 --- a/apps/netutils/discover/discover.c +++ b/apps/netutils/discover/discover.c @@ -270,25 +270,27 @@ static inline int discover_respond(in_addr_t *ipaddr) int ret; sockfd = discover_openresponder(); - if (sockfd >= 0) + if (sockfd < 0) { - /* Then send the reponse to the DHCP client port at that address */ + ndbg("discover_openresponder failed\n"); + return ERROR; + } - memset(&addr, 0, sizeof(struct sockaddr_in)); - addr.sin_family = AF_INET; - addr.sin_port = HTONS(CONFIG_DISCOVER_PORT); - addr.sin_addr.s_addr = *ipaddr; + /* Then send the reponse to the DHCP client port at that address */ - ret = sendto(sockfd, &g_state.response, sizeof(g_state.response), 0, - (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); - if (ret < 0) - { - ndbg("Could not send discovery response: %d\n", errno); - } + memset(&addr, 0, sizeof(struct sockaddr_in)); + addr.sin_family = AF_INET; + addr.sin_port = HTONS(CONFIG_DISCOVER_PORT); + addr.sin_addr.s_addr = *ipaddr; - close(sockfd); + ret = sendto(sockfd, &g_state.response, sizeof(g_state.response), 0, + (struct sockaddr *)&addr, sizeof(struct sockaddr_in)); + if (ret < 0) + { + ndbg("Could not send discovery response: %d\n", errno); } + close(sockfd); return ret; } diff --git a/apps/netutils/thttpd/libhttpd.c b/apps/netutils/thttpd/libhttpd.c index 34f829a28..f147125d5 100644 --- a/apps/netutils/thttpd/libhttpd.c +++ b/apps/netutils/thttpd/libhttpd.c @@ -519,7 +519,7 @@ static int send_err_file(httpd_conn *hc, int status, char *title, char *extrahea return 1; } -#endif +#endif /* CONFIG_THTTPD_ERROR_DIRECTORY */ #ifdef CONFIG_THTTPD_AUTH_FILE static void send_authenticate(httpd_conn *hc, char *realm) @@ -664,7 +664,8 @@ static int auth_check(httpd_conn *hc, char *dirname) case 1: return 1; } -#endif +#endif /* CONFIG_THTTPD_GLOBALPASSWD */ + return auth_check2(hc, dirname); } @@ -906,7 +907,7 @@ static int httpd_tilde_map1(httpd_conn *hc) (void)strcat(hc->expnfilename, temp); return 1; } -#endif +#endif /* CONFIG_THTTPD_TILDE_MAP1 */ /* Map a ~username/whatever URL into <user's homedir>/<postfix>. */ @@ -973,7 +974,7 @@ static int httpd_tilde_map2(httpd_conn *hc) hc->tildemapped = true; return 1; } -#endif +#endif /* CONFIG_THTTPD_TILDE_MAP2 */ /* Virtual host mapping. */ @@ -1030,6 +1031,7 @@ static int vhost_map(httpd_conn *hc) /* Figure out the host directory. */ #ifdef VHOST_DIRLEVELS + httpd_realloc_str(&hc->hostdir, &hc->maxhostdir, strlen(hc->vhostname) + 2 * VHOST_DIRLEVELS); if (strncmp(hc->vhostname, "www.", 4) == 0) { @@ -1070,10 +1072,13 @@ static int vhost_map(httpd_conn *hc) *cp2++ = '/'; } (void)strcpy(cp2, hc->vhostname); + #else /* VHOST_DIRLEVELS */ + httpd_realloc_str(&hc->hostdir, &hc->maxhostdir, strlen(hc->vhostname)); (void)strcpy(hc->hostdir, hc->vhostname); -#endif /* VHOST_DIRLEVELS */ + +#endif /* VHOST_DIRLEVELS */ /* Prepend hostdir to the filename. */ @@ -1134,7 +1139,7 @@ static char *expand_filename(char *path, char **restP, bool tildemapped) *restP = rest; return checked; } -#endif +#endif /* 0 */ /* Handle leading / or . and relative pathes by copying the default directory into checked */ @@ -1944,10 +1949,14 @@ static int check_referer(httpd_conn *hc) "You must supply a local referer to get URL '%s' from this server.\n"), hc->encodedurl); } + return r; -#else + +#else /* CONFIG_THTTPD_URLPATTERN */ + return 1; -#endif + +#endif /* CONFIG_THTTPD_URLPATTERN */ } /* Returns 1 if ok to serve the url, 0 if not. */ @@ -2035,25 +2044,23 @@ static int really_check_referer(httpd_conn *hc) return 1; } -#endif +#endif /* CONFIG_THTTPD_VHOST */ #endif /* CONFIG_THTTPD_LOCALPATTERN */ /* If the referer host doesn't match the local host pattern, and the * filename does match the url pattern, it's an illegal reference. */ -#ifdef CONFIG_THTTPD_URLPATTERN if (!match(lp, refhost) && match(CONFIG_THTTPD_URLPATTERN, hc->origfilename)) { return 0; } -#endif /* Otherwise ok. */ return 1; } -#endif +#endif /* CONFIG_THTTPD_URLPATTERN */ #ifdef CONFIG_DEBUG static int sockaddr_check(httpd_sockaddr *saP) @@ -2072,7 +2079,7 @@ static int sockaddr_check(httpd_sockaddr *saP) return 0; } } -#endif +#endif /* CONFIG_DEBUG */ static size_t sockaddr_len(httpd_sockaddr *saP) { @@ -2234,7 +2241,7 @@ void httpd_send_err(httpd_conn *hc, int status, const char *title, const char *e return; } } -#endif +#endif /* CONFIG_THTTPD_VHOST */ /* Try server-wide error page. */ @@ -2249,11 +2256,11 @@ void httpd_send_err(httpd_conn *hc, int status, const char *title, const char *e send_response(hc, status, title, extraheads, form, arg); -#else +#else /* CONFIG_THTTPD_ERROR_DIRECTORY */ send_response(hc, status, title, extraheads, form, arg); -#endif +#endif /* CONFIG_THTTPD_ERROR_DIRECTORY */ } const char *httpd_method_str(int method) @@ -2959,7 +2966,7 @@ int httpd_parse_request(httpd_conn *hc) { ndbg("unknown request header: %s\n", buf); } -#endif +#endif /* LOG_UNKNOWN_HEADERS */ } } @@ -3122,7 +3129,7 @@ void httpd_destroy_conn(httpd_conn *hc) httpd_free((void *)hc->buffer); #ifdef CONFIG_THTTPD_TILDE_MAP2 httpd_free((void *)hc->altdir); -#endif /*CONFIG_THTTPD_TILDE_MAP2 */ +#endif /*CONFIG_THTTPD_TILDE_MAP2 */ hc->initialized = 0; } } @@ -3134,7 +3141,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP) #ifdef CONFIG_THTTPD_AUTH_FILE static char *dirname; static size_t maxdirname = 0; -#endif /* CONFIG_THTTPD_AUTH_FILE */ +#endif /* CONFIG_THTTPD_AUTH_FILE */ size_t expnlen, indxlen; char *cp; char *pi; @@ -3258,8 +3265,10 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP) } /* Ok, generate an index. */ + return ls(hc); -#else +#else /* CONFIG_THTTPD_GENERATE_INDICES */ + ndbg("%s URL \"%s\" tried to index a directory\n", httpd_ntoa(&hc->client_addr), hc->encodedurl); httpd_send_err(hc, 403, err403title, "", @@ -3267,7 +3276,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP) "The requested URL '%s' is a directory, and directory indexing is disabled on this server.\n"), hc->encodedurl); return -1; -#endif +#endif /* CONFIG_THTTPD_GENERATE_INDICES */ got_one: @@ -3349,7 +3358,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval *nowP) hc->encodedurl); return -1; } -#endif +#endif /* CONFIG_THTTPD_AUTH_FILE */ /* Referer check. */ @@ -3455,7 +3464,7 @@ char *httpd_ntoa(httpd_sockaddr *saP) return inet_ntoa(saP->sin_addr); -#endif +#endif /* CONFIG_NET_IPv6 */ } /* Read to requested buffer, accounting for interruptions and EOF */ @@ -3523,4 +3532,3 @@ int httpd_write(int fd, const void *buf, size_t nbytes) } #endif /* CONFIG_THTTPD */ - |