kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject [2/2] incubator-kudu git commit: OS X: fix errno-test
Date Wed, 27 Jan 2016 01:30:42 GMT
OS X: fix errno-test

Change-Id: I6a594667a72c158f132ee171bb895e00f947510d
Reviewed-on: http://gerrit.cloudera.org:8080/1913
Reviewed-by: Todd Lipcon <todd@apache.org>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/a12d87e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/a12d87e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/a12d87e4

Branch: refs/heads/master
Commit: a12d87e4939221bdbfe372ea906840e053e39335
Parents: c555103
Author: Dan Burkert <dan@cloudera.com>
Authored: Tue Jan 26 17:01:30 2016 -0800
Committer: Todd Lipcon <todd@apache.org>
Committed: Wed Jan 27 01:30:13 2016 +0000

----------------------------------------------------------------------
 src/kudu/util/errno-test.cc |  3 ++-
 src/kudu/util/errno.cc      | 11 ++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/a12d87e4/src/kudu/util/errno-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/errno-test.cc b/src/kudu/util/errno-test.cc
index 32df662..911ca14 100644
--- a/src/kudu/util/errno-test.cc
+++ b/src/kudu/util/errno-test.cc
@@ -38,7 +38,8 @@ TEST(OsUtilTest, TestErrnoToString) {
   ASSERT_EQ("N", string(buf));
 
   // Unknown error.
-  ASSERT_EQ("Unknown error -1", ErrnoToString(-1));
+  string expected = "Unknown error";
+  ASSERT_EQ(ErrnoToString(-1).compare(0, expected.length(), expected), 0);
 
   // Unknown error (truncated).
   ErrnoToCString(-1, buf, arraysize(buf));

http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/a12d87e4/src/kudu/util/errno.cc
----------------------------------------------------------------------
diff --git a/src/kudu/util/errno.cc b/src/kudu/util/errno.cc
index 9c6a8a7..f08bf2f 100644
--- a/src/kudu/util/errno.cc
+++ b/src/kudu/util/errno.cc
@@ -29,13 +29,10 @@ void ErrnoToCString(int err, char *buf, size_t buf_len) {
 #if !defined(__GLIBC__) || \
   ((_POSIX_C_SOURCE >= 200112 || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
   // Using POSIX version 'int strerror_r(...)'.
-  if (strerror_r(err, buf, buf_len)) {
-    static const char UNKNOWN_ERROR[] = "unknown error";
-    if (buf_len >= sizeof(UNKNOWN_ERROR)) {
-      strcpy(buf, UNKNOWN_ERROR); // NOLINT(runtime/printf)
-    } else {
-      memset(buf, 0, buf_len);
-    }
+  int ret = strerror_r(err, buf, buf_len);
+  if (ret && ret != ERANGE && ret != EINVAL) {
+    strncpy(buf, "unknown error", buf_len);
+    buf[buf_len - 1] = '\0';
   }
 #else
   // Using GLIBC version


Mime
View raw message