qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kgiu...@apache.org
Subject qpid-proton git commit: PROTON-1029: do not crash if strerror fails
Date Wed, 28 Oct 2015 15:08:08 GMT
Repository: qpid-proton
Updated Branches:
  refs/heads/0.11.x abbc1e7f6 -> fe21523f5


PROTON-1029: do not crash if strerror fails


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/fe21523f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/fe21523f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/fe21523f

Branch: refs/heads/0.11.x
Commit: fe21523f54c735645a4f96f6b547459ed81e4e14
Parents: abbc1e7
Author: Ken Giusti <kgiusti@apache.org>
Authored: Fri Oct 23 16:50:59 2015 -0400
Committer: Ken Giusti <kgiusti@apache.org>
Committed: Wed Oct 28 10:59:54 2015 -0400

----------------------------------------------------------------------
 proton-c/src/platform.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fe21523f/proton-c/src/platform.c
----------------------------------------------------------------------
diff --git a/proton-c/src/platform.c b/proton-c/src/platform.c
index 5470c5a..3a8cade 100644
--- a/proton-c/src/platform.c
+++ b/proton-c/src/platform.c
@@ -65,25 +65,20 @@ pn_timestamp_t pn_i_now(void)
 }
 #endif
 
-#ifdef USE_STRERROR_R
 #include <string.h>
-static void pn_i_strerror(int errnum, char *buf, size_t buflen) {
-  if (strerror_r(errnum, buf, buflen) != 0) pni_fatal("strerror_r() failed\n");
-}
+#include <stdio.h>
+static void pn_i_strerror(int errnum, char *buf, size_t buflen)
+{
+  // PROTON-1029 provide a simple default in case strerror fails
+  snprintf(buf, buflen, "errno: %d", errnum);
+#ifdef USE_STRERROR_R
+  strerror_r(errnum, buf, buflen);
 #elif USE_STRERROR_S
-#include <string.h>
-static void pn_i_strerror(int errnum, char *buf, size_t buflen) {
-  if (strerror_s(buf, buflen, errnum) != 0) pni_fatal("strerror_s() failed\n");
-}
+  strerror_s(buf, buflen, errnum);
 #elif USE_OLD_STRERROR
-// This is thread safe on some platforms, and the only option on others
-#include <string.h>
-static void pn_i_strerror(int errnum, char *buf, size_t buflen) {
   strncpy(buf, strerror(errnum), buflen);
-}
-#else
-#error "Don't know a safe strerror equivalent for this platform"
 #endif
+}
 
 int pn_i_error_from_errno(pn_error_t *error, const char *msg)
 {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message