Repository: qpid-proton
Updated Branches:
refs/heads/master 6f8bc907c -> 7b4fa65a2
PROTON-1062: c++: Fix error message code in io.cpp.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2bc4d25b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2bc4d25b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2bc4d25b
Branch: refs/heads/master
Commit: 2bc4d25b143ce085364f2e03f368cd971aa62fab
Parents: 6f8bc90
Author: Alan Conway <aconway@redhat.com>
Authored: Tue Jan 26 13:19:17 2016 -0500
Committer: Alan Conway <aconway@redhat.com>
Committed: Wed Jan 27 16:49:21 2016 -0500
----------------------------------------------------------------------
proton-c/bindings/cpp/src/posix/io.cpp | 22 +++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2bc4d25b/proton-c/bindings/cpp/src/posix/io.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/posix/io.cpp b/proton-c/bindings/cpp/src/posix/io.cpp
index 2fef3ea..6532995 100644
--- a/proton-c/bindings/cpp/src/posix/io.cpp
+++ b/proton-c/bindings/cpp/src/posix/io.cpp
@@ -34,22 +34,14 @@ namespace io {
const descriptor INVALID_DESCRIPTOR = -1;
std::string error_str() {
-#ifdef USE_STRERROR_R
- char buf[256];
- strerror_r(errno, buf, sizeof(buf));
- return buf;
-#elifdef USE_STRERROR_S
- char buf[256];
- strerror_s(buf, sizeof(buf), errno);
- return buf;
-#elifdef USE_OLD_STRERROR
- char buf[256];
- strncpy(buf, strerror(errno), sizeof(buf));
- return buf;
+ char buf[512] = "Unknown error";
+#ifdef _GNU_SOURCE
+ // GNU strerror_r returns the message
+ return ::strerror_r(errno, buf, sizeof(buf));
#else
- std::ostringstream os;
- os << "system error (" << errno << ")";
- return os.str();
+ // POSIX strerror_r doesn't return the buffer
+ ::strerror_r(errno, buf, sizeof(buf));
+ return std::string(buf)
#endif
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org
|