mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
Merge branch 'fix/coverity_wl_overflow_constant' into 'master'
fix(wear_levelling): Fix coverity issue overflowed constant in WL_Flash.cpp See merge request espressif/esp-idf!35204
This commit is contained in:
commit
64960f0751
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -127,7 +127,7 @@ esp_err_t WL_Flash::init()
|
|||||||
WL_RESULT_CHECK(result);
|
WL_RESULT_CHECK(result);
|
||||||
|
|
||||||
int check_size = WL_STATE_CRC_LEN_V2;
|
int check_size = WL_STATE_CRC_LEN_V2;
|
||||||
// Chech CRC and recover state
|
// Check CRC and recover state
|
||||||
uint32_t crc1 = crc32::crc32_le(WL_CFG_CRC_CONST, (uint8_t *)&this->state, check_size);
|
uint32_t crc1 = crc32::crc32_le(WL_CFG_CRC_CONST, (uint8_t *)&this->state, check_size);
|
||||||
uint32_t crc2 = crc32::crc32_le(WL_CFG_CRC_CONST, (uint8_t *)state_copy, check_size);
|
uint32_t crc2 = crc32::crc32_le(WL_CFG_CRC_CONST, (uint8_t *)state_copy, check_size);
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ esp_err_t WL_Flash::recoverPos()
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->state.wl_dummy_sec_pos = position;
|
this->state.wl_dummy_sec_pos = position;
|
||||||
if (this->state.wl_dummy_sec_pos == this->state.wl_part_max_sec_pos) {
|
if (this->state.wl_dummy_sec_pos == this->state.wl_part_max_sec_pos && this->state.wl_dummy_sec_pos != 0) {
|
||||||
this->state.wl_dummy_sec_pos--;
|
this->state.wl_dummy_sec_pos--;
|
||||||
}
|
}
|
||||||
ESP_LOGD(TAG, "%s - this->state.wl_dummy_sec_pos= 0x%08" PRIx32 ", position= 0x%08" PRIx32 ", result= 0x%08" PRIx32 ", wl_part_max_sec_pos= 0x%08" PRIx32 , __func__, (uint32_t)this->state.wl_dummy_sec_pos, (uint32_t)position, (uint32_t)result, (uint32_t)this->state.wl_part_max_sec_pos);
|
ESP_LOGD(TAG, "%s - this->state.wl_dummy_sec_pos= 0x%08" PRIx32 ", position= 0x%08" PRIx32 ", result= 0x%08" PRIx32 ", wl_part_max_sec_pos= 0x%08" PRIx32 , __func__, (uint32_t)this->state.wl_dummy_sec_pos, (uint32_t)position, (uint32_t)result, (uint32_t)this->state.wl_part_max_sec_pos);
|
||||||
@ -325,7 +325,7 @@ esp_err_t WL_Flash::updateV1_V2()
|
|||||||
// Check crc for old version and old version
|
// Check crc for old version and old version
|
||||||
ESP_LOGV(TAG, "%s start", __func__);
|
ESP_LOGV(TAG, "%s start", __func__);
|
||||||
int check_size = WL_STATE_CRC_LEN_V1;
|
int check_size = WL_STATE_CRC_LEN_V1;
|
||||||
// Chech CRC and recover state
|
// Check CRC and recover state
|
||||||
uint32_t crc1 = crc32::crc32_le(WL_CFG_CRC_CONST, (uint8_t *)&this->state, check_size);
|
uint32_t crc1 = crc32::crc32_le(WL_CFG_CRC_CONST, (uint8_t *)&this->state, check_size);
|
||||||
wl_state_t sa_copy;
|
wl_state_t sa_copy;
|
||||||
wl_state_t *state_copy = &sa_copy;
|
wl_state_t *state_copy = &sa_copy;
|
||||||
@ -355,7 +355,7 @@ esp_err_t WL_Flash::updateV1_V2()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "%s wl_part_max_sec_pos=%" PRIu32 ", pos=%" PRIu32 ", state.ver=%" PRIu32 ", state2.ver=%" PRIu32, __func__, (uint32_t) this->state.wl_part_max_sec_pos, (uint32_t) pos, (uint32_t) this->state.version, (uint32_t) state_copy->version);
|
ESP_LOGI(TAG, "%s wl_part_max_sec_pos=%" PRIu32 ", pos=%" PRIu32 ", state.ver=%" PRIu32 ", state2.ver=%" PRIu32, __func__, (uint32_t) this->state.wl_part_max_sec_pos, (uint32_t) pos, (uint32_t) this->state.version, (uint32_t) state_copy->version);
|
||||||
if (pos == this->state.wl_part_max_sec_pos) {
|
if (pos == this->state.wl_part_max_sec_pos && pos != 0) {
|
||||||
pos--;
|
pos--;
|
||||||
}
|
}
|
||||||
WL_RESULT_CHECK(result);
|
WL_RESULT_CHECK(result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user