Fix various warnings generated from Coverity scan

esp_timer:
Control flow issues  (DEADCODE)
    Execution cannot reach this statement: "break;".

protocomm_httpd:
(UNUSED_VALUE)
    Assigning value from "cookie_session_id" to "cur_cookie_session_id" here, but that stored value is overwritten before it can be used.

esp_flash_api:
Null pointer dereferences  (REVERSE_INULL)
    Null-checking "chip" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
This commit is contained in:
Mahavir Jain 2021-12-07 13:21:08 +05:30
parent 13978c9556
commit 203f82cc49
4 changed files with 9 additions and 21 deletions

View File

@ -605,11 +605,8 @@ int64_t IRAM_ATTR esp_timer_get_next_alarm_for_wake_up(void)
int64_t next_alarm = INT64_MAX;
for (esp_timer_dispatch_t dispatch_method = ESP_TIMER_TASK; dispatch_method < ESP_TIMER_MAX; ++dispatch_method) {
timer_list_lock(dispatch_method);
esp_timer_handle_t it;
esp_timer_handle_t it = NULL;
LIST_FOREACH(it, &s_timers[dispatch_method], list_entry) {
if (it == NULL) {
break;
}
// timers with the SKIP_UNHANDLED_EVENTS flag do not want to wake up CPU from a sleep mode.
if ((it->flags & FL_SKIP_UNHANDLED_EVENTS) == 0) {
if (next_alarm > it->alarm) {

View File

@ -1,16 +1,8 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
@ -69,7 +61,6 @@ static esp_err_t common_post_handler(httpd_req_t *req)
*/
if (strcmp(session_cookie, cookie_buf) == 0) {
ESP_LOGD(TAG, "Continuing Session %u", cookie_session_id);
cur_cookie_session_id = cookie_session_id;
/* If we reach here, it means that the client supports cookies and so the
* socket session id would no more be required for checking.
*/
@ -79,7 +70,6 @@ static esp_err_t common_post_handler(httpd_req_t *req)
} else if (cur_sock_session_id == sock_session_id) {
/* If the socket number matches, we assume it to be the same session */
ESP_LOGD(TAG, "Continuing Socket Session %u", sock_session_id);
cur_cookie_session_id = cookie_session_id;
same_session = true;
}
if (!same_session) {

View File

@ -265,12 +265,14 @@ esp_err_t IRAM_ATTR esp_flash_init_main(esp_flash_t *chip)
// 3. Get basic parameters of the chip (size, dummy count, etc.)
// 4. Init chip into desired mode (without breaking the cache!)
esp_err_t err = ESP_OK;
bool octal_mode = (chip->read_mode >= SPI_FLASH_OPI_FLAG);
bool octal_mode;
if (chip == NULL || chip->host == NULL || chip->host->driver == NULL ||
((memspi_host_inst_t*)chip->host)->spi == NULL) {
return ESP_ERR_INVALID_ARG;
}
octal_mode = (chip->read_mode >= SPI_FLASH_OPI_FLAG);
//read chip id
// This can indicate the MSPI support OPI, if the flash works on MSPI in OPI mode, we directly bypass read id.
uint32_t flash_id = 0;

View File

@ -1707,7 +1707,6 @@ components/protocomm/src/common/protocomm_priv.h
components/protocomm/src/security/security0.c
components/protocomm/src/security/security1.c
components/protocomm/src/transports/protocomm_console.c
components/protocomm/src/transports/protocomm_httpd.c
components/protocomm/test/test_protocomm.c
components/pthread/include/esp_pthread.h
components/pthread/pthread_cond_var.c