Fix ESP8266 climate memaccess warning (#3226)

This commit is contained in:
Otto Winter 2022-02-19 14:11:45 +01:00 committed by GitHub
parent d594f43ebd
commit 0c1520dd9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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