0
0
mirror of https://github.com/openwrt/routing.git synced 2025-01-31 08:21:24 +00:00
routing/ndppd/patches/0002-Fixes-strerror_r-GNU-XSI.patch
谢致邦 (XIE Zhibang) 8f5ed0f95f ndppd: update to version 0.2.6
Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>
2024-11-14 21:42:30 +01:00

52 lines
1.2 KiB
Diff

From 1f610129b475b417509b251e022ad46d2210ff50 Mon Sep 17 00:00:00 2001
From: Rafael Cossovan <navossoc@gmail.com>
Date: Tue, 3 Apr 2018 17:04:35 -0300
Subject: [PATCH 2/3] Fixes strerror_r GNU/XSI issue #40.
http://www.zverovich.net/2015/03/13/reliable-detection-of-strerror-variants.html
---
src/logger.cc | 14 ++++++++++++-
src/logger.h | 3 +++
2 files changed, 15 insertions(+), 1 deletions(-)
--- a/src/logger.cc
+++ b/src/logger.cc
@@ -89,7 +89,7 @@ std::string logger::err()
return "Unknown error";
return buf;
#else
- return strerror_r(errno, buf, sizeof(buf));
+ return strerror_r_wrapper(strerror_r(errno, buf, sizeof(buf)), buf);
#endif
}
@@ -228,4 +228,16 @@ bool logger::verbosity(const std::string
return false;
}
+// XSI-compliant: int
+std::string logger::strerror_r_wrapper(int, char* s)
+{
+ return s;
+}
+
+// GNU-specific: char *
+std::string logger::strerror_r_wrapper(char* s, char*)
+{
+ return s;
+}
+
NDPPD_NS_END
--- a/src/logger.h
+++ b/src/logger.h
@@ -91,6 +91,9 @@ private:
static int _max_pri;
+ // helpers for strerror_r
+ static std::string strerror_r_wrapper(int, char* s);
+ static std::string strerror_r_wrapper(char* s, char*);
};