Fix ESP8266 climate memaccess warning (#3226)

This commit is contained in:
Otto Winter 2022-02-19 14:11:45 +01:00 committed by Jesse Hills
parent 0c4de2bc97
commit 616c787e37
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A

View File

@ -1,4 +1,5 @@
#include "climate.h"
#include "esphome/core/macros.h"
namespace esphome {
namespace climate {
@ -326,14 +327,17 @@ optional<ClimateDeviceRestoreState> Climate::restore_state_() {
return recovered;
}
void Climate::save_state_() {
#if defined(USE_ESP_IDF) && !defined(CLANG_TIDY)
#if (defined(USE_ESP_IDF) || (defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0))) && \
!defined(CLANG_TIDY)
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#define TEMP_IGNORE_MEMACCESS
#endif
ClimateDeviceRestoreState state{};
// initialize as zero to prevent random data on stack triggering erase
memset(&state, 0, sizeof(ClimateDeviceRestoreState));
#if USE_ESP_IDF && !defined(CLANG_TIDY)
#ifdef TEMP_IGNORE_MEMACCESS
#pragma GCC diagnostic pop
#undef TEMP_IGNORE_MEMACCESS
#endif
state.mode = this->mode;