From 278d82dec6f32fd5beda58cb7f40e8acaab944d8 Mon Sep 17 00:00:00 2001 From: Nicu Hodos Date: Fri, 3 May 2024 13:55:19 +0200 Subject: [PATCH] fix random resets by initializing all pointers with nullptr --- gateway/include/ha.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/gateway/include/ha.h b/gateway/include/ha.h index e0f1b42..108ef84 100644 --- a/gateway/include/ha.h +++ b/gateway/include/ha.h @@ -10,11 +10,11 @@ namespace Ha { uint16_t (*publisher)(const char* topic, const char* message); struct DeviceConfig { - const char* id; - const char* name; - const char* model; - const char* manufacturer; - const char* area; + const char* id = nullptr; + const char* name = nullptr; + const char* model = nullptr; + const char* manufacturer = nullptr; + const char* area = nullptr; DeviceConfig* parent = nullptr; DeviceConfig(const char* id, const char* name) : id(id), name(name) {} @@ -56,14 +56,14 @@ namespace Ha { }; struct Component { + const char* name = nullptr; char* id = nullptr; - const char* name; - const char* type; + const char* type = nullptr; char configTopic[TOPIC_SIZE]; DeviceConfig* mainDevice = nullptr; static List components; - Component(const char* name, const char* id, const char* type) : id((char*)id), name(name), type(type) { + Component(const char* name, const char* id, const char* type) : name(name), id((char*)id), type(type) { sprintf(configTopic, "homeassistant/%s/%s/%s/config", type, MAIN_DEVICE_ID, id); components.add(this); } @@ -136,7 +136,6 @@ namespace Ha { }; struct Switch : Command, StateConfig { - const char* area; virtual void onCommand(const char* msg){}