From 95ab9e42654dc0d65a17e66029e871b805368f72 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Wed, 11 Oct 2023 11:01:45 +0100 Subject: [PATCH 1/2] Provide workaround for 'dangling pointer' error/warning --- Sming/Wiring/FakePgmSpace.cpp | 7 +++++++ Sming/Wiring/FakePgmSpace.h | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Sming/Wiring/FakePgmSpace.cpp b/Sming/Wiring/FakePgmSpace.cpp index 156a31df6c..847c227528 100644 --- a/Sming/Wiring/FakePgmSpace.cpp +++ b/Sming/Wiring/FakePgmSpace.cpp @@ -38,3 +38,10 @@ int memcmp_aligned(const void* ptr1, const void* ptr2, unsigned len) auto tail2 = pgm_read_dword(reinterpret_cast(ptr2) + len_aligned); return memcmp(&tail1, &tail2, len - len_aligned); } + +#ifdef ARCH_HOST +char* smg_return_local(char* buf) +{ + return buf; +} +#endif diff --git a/Sming/Wiring/FakePgmSpace.h b/Sming/Wiring/FakePgmSpace.h index 62d02ad7b7..db5fab597a 100644 --- a/Sming/Wiring/FakePgmSpace.h +++ b/Sming/Wiring/FakePgmSpace.h @@ -75,6 +75,13 @@ extern "C" { &__pstr__[0]; \ })) +#ifdef ARCH_HOST +// Internal function to prevent 'dangling pointer' compiler warning +extern char* smg_return_local(char* buf); +#else +#define smg_return_local(buf) (buf) +#endif + /** * @brief Declare and use a flash string inline. * @param str @@ -84,7 +91,7 @@ extern "C" { (__extension__({ \ DEFINE_PSTR_LOCAL(__pstr__, str); \ LOAD_PSTR(buf, __pstr__); \ - buf; \ + smg_return_local(buf); \ })) /** From 5b4812f185c5a0d492a64eedb258ca1d0a2146c1 Mon Sep 17 00:00:00 2001 From: mikee47 Date: Thu, 12 Oct 2023 09:28:09 +0100 Subject: [PATCH 2/2] Fix failing FlashString test --- Sming/Components/FlashString | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sming/Components/FlashString b/Sming/Components/FlashString index 1025908632..d9a0a50e4d 160000 --- a/Sming/Components/FlashString +++ b/Sming/Components/FlashString @@ -1 +1 @@ -Subproject commit 10259086321ebeceb6b7106b4697c9caef9956e6 +Subproject commit d9a0a50e4d91f0d7ba68166cae6e0d52ac474453