You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by kg...@apache.org on 2015/10/28 13:57:12 UTC
qpid-proton git commit: PROTON-1029: do not crash if strerror fails
Repository: qpid-proton
Updated Branches:
refs/heads/master 55abbc8e3 -> 7c132f353
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/7c132f35
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/7c132f35
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/7c132f35
Branch: refs/heads/master
Commit: 7c132f35392448d2623a01915ea9ce6303453162
Parents: 55abbc8
Author: Ken Giusti <kg...@apache.org>
Authored: Fri Oct 23 16:50:59 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed Oct 28 08:48:46 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/7c132f35/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