From 31efbe915e587f5c5d3dfe51e118a284dcbfbe37 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Wed, 14 Jun 2023 20:45:00 +0200 Subject: [PATCH] Minor string optimisation. --- usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h index 79983dc4..8a4b9a60 100644 --- a/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h +++ b/usermods/PIR_sensor_switch/usermod_PIR_sensor_switch.h @@ -271,10 +271,9 @@ void PIRsensorSwitch::publishMqtt(const char* state) #ifndef WLED_DISABLE_MQTT //Check if MQTT Connected, otherwise it will crash the 8266 if (WLED_MQTT_CONNECTED) { - char subuf[64]; - strcpy(subuf, mqttDeviceTopic); - strcat_P(subuf, PSTR("/motion")); - mqtt->publish(subuf, 0, false, state); + char buf[64]; + sprintf_P(buf, PSTR("%s/motion"), mqttDeviceTopic); //max length: 33 + 7 = 40 + mqtt->publish(buf, 0, false, state); } #endif }