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 <cfriedt@fb.com>
diff --git a/lib/cpp/src/thrift/TOutput.cpp b/lib/cpp/src/thrift/TOutput.cpp
index a30879a..971e5db 100644
--- a/lib/cpp/src/thrift/TOutput.cpp
+++ b/lib/cpp/src/thrift/TOutput.cpp
@@ -105,6 +105,9 @@
}
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 @@
// to ensure that the string object is constructed before
// b_error becomes invalid?
return std::string(b_error);
+#endif // __ZEPHYR__
}
}
} // apache::thrift