From 0f99a4c969c4c7dbbbec336b48e4df8553301976 Mon Sep 17 00:00:00 2001 From: etrinh Date: Thu, 2 Apr 2020 22:10:50 +0200 Subject: [PATCH] Fix compilation warning STM32 uses TP --- src/knx/dptconvert.cpp | 10 ++++++---- src/knx/knx_value.cpp | 2 +- src/knx_facade.cpp | 2 +- src/knx_facade.h | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/knx/dptconvert.cpp b/src/knx/dptconvert.cpp index 5da8fde..1c5a734 100644 --- a/src/knx/dptconvert.cpp +++ b/src/knx/dptconvert.cpp @@ -1723,8 +1723,9 @@ double float16FromPayload(const uint8_t* payload, int index) } float float32FromPayload(const uint8_t* payload, int index) { - uint32_t area = unsigned32FromPayload(payload, index); - return *((float*)&area); + union { float f; uint32_t i; } area; + area.i = unsigned32FromPayload(payload, index); + return area.f; } int64_t signed64FromPayload(const uint8_t* payload, int index) { @@ -1815,8 +1816,9 @@ void float16ToPayload(uint8_t* payload, size_t payload_length, int index, double } void float32ToPayload(uint8_t* payload, size_t payload_length, int index, double value, uint32_t mask) { - float num = value; - unsigned32ToPayload(payload, payload_length, index, *((uint32_t*)&num), mask); + union { float f; uint32_t i; } num; + num.f = value; + unsigned32ToPayload(payload, payload_length, index, num.i, mask); } void signed64ToPayload(uint8_t* payload, size_t payload_length, int index, int64_t value, uint64_t mask) { diff --git a/src/knx/knx_value.cpp b/src/knx/knx_value.cpp index 7b6f93a..22d3e85 100644 --- a/src/knx/knx_value.cpp +++ b/src/knx/knx_value.cpp @@ -526,7 +526,7 @@ struct tm KNXValue::timeValue() const return *timePtr; } } - struct tm tmp; + struct tm tmp = {0}; return tmp; } diff --git a/src/knx_facade.cpp b/src/knx_facade.cpp index ba5e766..7219cb0 100644 --- a/src/knx_facade.cpp +++ b/src/knx_facade.cpp @@ -23,7 +23,7 @@ // predefined global instance for IP only KnxFacade knx; #elif ARDUINO_ARCH_STM32 - KnxFacade knx; + KnxFacade knx; // no predefined global instance #define ICACHE_RAM_ATTR #elif __linux__ diff --git a/src/knx_facade.h b/src/knx_facade.h index 108b7be..7aa862c 100644 --- a/src/knx_facade.h +++ b/src/knx_facade.h @@ -20,7 +20,7 @@ #include "knx/bau57B0.h" #elif ARDUINO_ARCH_STM32 #include "stm32_platform.h" - #include "knx/bau57B0.h" + #include "knx/bau07B0.h" #else #define LED_BUILTIN 0 #include "linux_platform.h" @@ -338,7 +338,7 @@ template class KnxFacade : private SaveRestore extern KnxFacade knx; #elif ARDUINO_ARCH_STM32 // predefined global instance for TP only - extern KnxFacade knx; + extern KnxFacade knx; #elif __linux__ // no predefined global instance #endif