Repository: qpid-proton
Updated Branches:
  refs/heads/fix [created] 6cee4cac3


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/68f7d3cd
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/68f7d3cd
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/68f7d3cd

Branch: refs/heads/fix
Commit: 68f7d3cd51512a6fa33c67456337296a9c0f4657
Parents: 5ec9013
Author: Alan Conway <[email protected]>
Authored: Tue Jan 26 13:19:17 2016 -0500
Committer: Alan Conway <[email protected]>
Committed: Tue Jan 26 13:48:16 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/68f7d3cd/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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to