From 6aba57bb6b0201f2138a503cbf22123901f32f72 Mon Sep 17 00:00:00 2001 From: Chris Friedt Date: Mon, 26 Sep 2022 15:17:53 -0400 Subject: lib: cpp: TOutput: add zephyr-specific strerror_s implementation In Zephyr, optimize `TOutput::strerror_s` to minimize (stack) space. The string error table is in ROM in any case, so string values will not be overwritten (if they happen to be compiled-in). Signed-off-by: Chris Friedt --- lib/cpp/src/thrift/TOutput.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp index a30879acd..971e5dbf7 100644 --- a/lib/cpp/src/thrift/TOutput.cpp +++ b/lib/cpp/src/thrift/TOutput.cpp @@ -105,6 +105,9 @@ void TOutput::perror(const char* message, int errno_copy) { } std::string TOutput::strerror_s(int errno_copy) { +#ifdef __ZEPHYR__ + return std::string(strerror(errno_copy)); +#else char b_errbuf[1024] = {'\0'}; #ifdef HAVE_STRERROR_R @@ -139,6 +142,7 @@ std::string TOutput::strerror_s(int errno_copy) { // to ensure that the string object is constructed before // b_error becomes invalid? return std::string(b_error); +#endif // __ZEPHYR__ } } } // apache::thrift -- cgit v1.2.1