summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Friedt <cfriedt@fb.com>2022-09-26 15:17:53 -0400
committerJens Geyer <Jens-G@users.noreply.github.com>2022-10-25 22:27:49 +0200
commit6aba57bb6b0201f2138a503cbf22123901f32f72 (patch)
tree3cddcf27031c5900e9cec1208706cc289ca7f733
parent0bc818f363a50282910fa19ae605689954239fcb (diff)
downloadthrift-6aba57bb6b0201f2138a503cbf22123901f32f72.tar.gz
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>
-rw-r--r--lib/cpp/src/thrift/TOutput.cpp4
1 files changed, 4 insertions, 0 deletions
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