mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_http_server: fix few coverity warnings
- unreachable code - uninitialized values - missing return checks
This commit is contained in:
parent
a7b42be1bd
commit
fffc72d307
@ -55,12 +55,16 @@ static esp_err_t httpd_accept_conn(struct httpd_data *hd, int listen_fd)
|
||||
/* Set recv timeout of this fd as per config */
|
||||
tv.tv_sec = hd->config.recv_wait_timeout;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(new_fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv));
|
||||
if (setsockopt(new_fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)) < 0) {
|
||||
ESP_LOGW(TAG, LOG_FMT("error enabling SO_RCVTIMEO (%d)"), errno);
|
||||
}
|
||||
|
||||
/* Set send timeout of this fd as per config */
|
||||
tv.tv_sec = hd->config.send_wait_timeout;
|
||||
tv.tv_usec = 0;
|
||||
setsockopt(new_fd, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv));
|
||||
if (setsockopt(new_fd, SOL_SOCKET, SO_SNDTIMEO, (const char *)&tv, sizeof(tv)) < 0) {
|
||||
ESP_LOGW(TAG, LOG_FMT("error enabling SO_SNDTIMEO (%d)"), errno);
|
||||
}
|
||||
|
||||
if (ESP_OK != httpd_sess_new(hd, new_fd)) {
|
||||
ESP_LOGW(TAG, LOG_FMT("session creation failed"));
|
||||
|
@ -63,8 +63,9 @@ static esp_err_t verify_url (http_parser *parser)
|
||||
const char *at = parser_data->last.at;
|
||||
size_t length = parser_data->last.length;
|
||||
|
||||
if ((r->method = parser->method) < 0) {
|
||||
ESP_LOGW(TAG, LOG_FMT("HTTP Operation not supported"));
|
||||
r->method = parser->method;
|
||||
if (r->method < 0) {
|
||||
ESP_LOGW(TAG, LOG_FMT("HTTP method not supported (%d)"), r->method);
|
||||
parser_data->error = HTTPD_501_METHOD_NOT_IMPLEMENTED;
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@ -618,8 +619,8 @@ static esp_err_t httpd_parse_req(struct httpd_data *hd)
|
||||
{
|
||||
httpd_req_t *r = &hd->hd_req;
|
||||
int blk_len, offset;
|
||||
http_parser parser;
|
||||
parser_data_t parser_data;
|
||||
http_parser parser = {};
|
||||
parser_data_t parser_data = {};
|
||||
|
||||
/* Initialize parser */
|
||||
parse_init(r, &parser, &parser_data);
|
||||
|
@ -359,7 +359,9 @@ void httpd_sess_delete(struct httpd_data *hd, struct sock_db *session)
|
||||
.l_onoff = true,
|
||||
.l_linger = hd->config.linger_timeout,
|
||||
};
|
||||
setsockopt(session->fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(struct linger));
|
||||
if (setsockopt(session->fd, SOL_SOCKET, SO_LINGER, &so_linger, sizeof(struct linger)) < 0) {
|
||||
ESP_LOGW(TAG, LOG_FMT("error enabling SO_LINGER (%d)"), errno);
|
||||
}
|
||||
}
|
||||
|
||||
// Call close function if defined
|
||||
|
Loading…
Reference in New Issue
Block a user