You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by mp...@apache.org on 2017/01/10 00:28:22 UTC

[1/3] mesos git commit: Cleaned up `std::string` usage in stout.

Repository: mesos
Updated Branches:
  refs/heads/master e251f25bb -> c0aee8cc1


Cleaned up `std::string` usage in stout.

- Avoided redundant initialization to empty string.
- Used `char` overloads instead for single-character string literals.

Spotted with `clang-tidy`.

Review: https://reviews.apache.org/r/55219/


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

Branch: refs/heads/master
Commit: bf6cd2eee7383156b80fe5c7c168bdad66fd0dea
Parents: e251f25
Author: Neil Conway <ne...@gmail.com>
Authored: Mon Jan 9 14:24:18 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jan 9 16:28:03 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/flags/flags.hpp | 4 ++--
 3rdparty/stout/include/stout/gzip.hpp        | 2 +-
 3rdparty/stout/include/stout/os/mkdir.hpp    | 2 +-
 3rdparty/stout/include/stout/path.hpp        | 2 +-
 3rdparty/stout/tests/ip_tests.cpp            | 4 ++--
 5 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bf6cd2ee/3rdparty/stout/include/stout/flags/flags.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/flags/flags.hpp b/3rdparty/stout/include/stout/flags/flags.hpp
index 61d17a9..4de093d 100644
--- a/3rdparty/stout/include/stout/flags/flags.hpp
+++ b/3rdparty/stout/include/stout/flags/flags.hpp
@@ -597,7 +597,7 @@ inline Try<Warnings> FlagsBase::load(
     std::string name;
     Option<std::string> value = None();
 
-    size_t eq = arg.find_first_of("=");
+    size_t eq = arg.find_first_of('=');
     if (eq == std::string::npos && arg.find("--no-") == 0) { // --no-name
       name = arg.substr(2);
     } else if (eq == std::string::npos) {                    // --name
@@ -653,7 +653,7 @@ inline Try<Warnings> FlagsBase::load(
     std::string name;
     Option<std::string> value = None();
 
-    size_t eq = arg.find_first_of("=");
+    size_t eq = arg.find_first_of('=');
     if (eq == std::string::npos && arg.find("--no-") == 0) { // --no-name
       name = arg.substr(2);
     } else if (eq == std::string::npos) {                    // --name

http://git-wip-us.apache.org/repos/asf/mesos/blob/bf6cd2ee/3rdparty/stout/include/stout/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/gzip.hpp b/3rdparty/stout/include/stout/gzip.hpp
index 9789186..7040a32 100644
--- a/3rdparty/stout/include/stout/gzip.hpp
+++ b/3rdparty/stout/include/stout/gzip.hpp
@@ -209,7 +209,7 @@ inline Try<std::string> compress(
 
   // Build up the compressed result.
   Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
+  std::string result;
   do {
     stream.next_out = buffer;
     stream.avail_out = GZIP_BUFFER_SIZE;

http://git-wip-us.apache.org/repos/asf/mesos/blob/bf6cd2ee/3rdparty/stout/include/stout/os/mkdir.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/mkdir.hpp b/3rdparty/stout/include/stout/os/mkdir.hpp
index fe86864..b384391 100644
--- a/3rdparty/stout/include/stout/os/mkdir.hpp
+++ b/3rdparty/stout/include/stout/os/mkdir.hpp
@@ -44,7 +44,7 @@ inline Try<Nothing> mkdir(const std::string& directory, bool recursive = true)
     std::vector<std::string> tokens =
       strings::tokenize(directory, stringify(os::PATH_SEPARATOR));
 
-    std::string path = "";
+    std::string path;
 
     // We got an absolute path, so keep the leading slash.
     if (directory.find_first_of(stringify(os::PATH_SEPARATOR)) == 0) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/bf6cd2ee/3rdparty/stout/include/stout/path.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/path.hpp b/3rdparty/stout/include/stout/path.hpp
index d1092f6..2d2088a 100644
--- a/3rdparty/stout/include/stout/path.hpp
+++ b/3rdparty/stout/include/stout/path.hpp
@@ -227,7 +227,7 @@ public:
   inline Option<std::string> extension() const
   {
     std::string _basename = basename();
-    size_t index = _basename.rfind(".");
+    size_t index = _basename.rfind('.');
 
     if (_basename == "." || _basename == ".." || index == std::string::npos) {
       return None();

http://git-wip-us.apache.org/repos/asf/mesos/blob/bf6cd2ee/3rdparty/stout/tests/ip_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/ip_tests.cpp b/3rdparty/stout/tests/ip_tests.cpp
index 84eb75e..930365b 100644
--- a/3rdparty/stout/tests/ip_tests.cpp
+++ b/3rdparty/stout/tests/ip_tests.cpp
@@ -46,12 +46,12 @@ TEST_TEMP_DISABLED_ON_WINDOWS(NetTest, LinkDevice)
 
     if (network.isSome()) {
       string addr = stringify(network.get());
-      string prefix = addr.substr(addr.find("/") + 1);
+      string prefix = addr.substr(addr.find('/') + 1);
       ASSERT_SOME(numify<int>(prefix));
       EXPECT_EQ(network.get().prefix(), numify<int>(prefix).get());
 
       vector<string> tokens =
-        strings::split(addr.substr(0, addr.find("/")), ".");
+        strings::split(addr.substr(0, addr.find('/')), ".");
 
       EXPECT_EQ(4u, tokens.size());
 


[2/3] mesos git commit: Cleaned up `std::string` usage in libprocess.

Posted by mp...@apache.org.
Cleaned up `std::string` usage in libprocess.

- Avoided redundant initialization to empty string.
- Used `char` overloads instead for single-character string literals.

Spotted with `clang-tidy`.

Review: https://reviews.apache.org/r/55226/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9fcb719e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9fcb719e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9fcb719e

Branch: refs/heads/master
Commit: 9fcb719e4525da39aba9eccf497711f35a7885fc
Parents: bf6cd2e
Author: Neil Conway <ne...@gmail.com>
Authored: Mon Jan 9 14:24:20 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jan 9 16:28:06 2017 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/src/http.cpp           | 2 +-
 3rdparty/libprocess/src/tests/io_tests.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9fcb719e/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index 131f7ae..b5c38ce 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -199,7 +199,7 @@ Try<URL> URL::parse(const string& urlString)
   const string scheme = strings::lower(urlString.substr(0, schemePos));
   const string urlPath = urlString.substr(schemePos + 3);
 
-  size_t pathPos = urlPath.find_first_of("/");
+  size_t pathPos = urlPath.find_first_of('/');
   if (pathPos == 0) {
     return Error("Host not found in url");
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/9fcb719e/3rdparty/libprocess/src/tests/io_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/io_tests.cpp b/3rdparty/libprocess/src/tests/io_tests.cpp
index b9825e8..466e343 100644
--- a/3rdparty/libprocess/src/tests/io_tests.cpp
+++ b/3rdparty/libprocess/src/tests/io_tests.cpp
@@ -323,7 +323,7 @@ TEST_F(IOTest, Redirect)
   ASSERT_SOME(os::nonblock(pipes[1]));
 
   // Set up a redirect hook to also accumlate the data that we splice.
-  string accumulated = "";
+  string accumulated;
   lambda::function<void(const string&)> hook =
     [&accumulated](const string& data) {
       accumulated += data;


[3/3] mesos git commit: Cleaned up `std::string` usage in mesos.

Posted by mp...@apache.org.
Cleaned up `std::string` usage in mesos.

- Avoided redundant initialization to empty string.
- Used `char` overloads instead for single-character string literals.

Spotted with `clang-tidy`.

Review: https://reviews.apache.org/r/55220/


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

Branch: refs/heads/master
Commit: c0aee8cc10b1d1f4b2db5ff12b771372fdd5b1f3
Parents: 9fcb719
Author: Neil Conway <ne...@gmail.com>
Authored: Mon Jan 9 14:24:22 2017 -0800
Committer: Michael Park <mp...@apache.org>
Committed: Mon Jan 9 16:28:08 2017 -0800

----------------------------------------------------------------------
 src/common/resources.cpp            | 4 ++--
 src/docker/docker.cpp               | 2 +-
 src/slave/containerizer/fetcher.cpp | 4 ++--
 src/state/zookeeper.cpp             | 4 ++--
 src/tests/environment.cpp           | 2 +-
 src/v1/resources.cpp                | 4 ++--
 src/zookeeper/zookeeper.cpp         | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/common/resources.cpp
----------------------------------------------------------------------
diff --git a/src/common/resources.cpp b/src/common/resources.cpp
index 7dbeefc..be9bca2 100644
--- a/src/common/resources.cpp
+++ b/src/common/resources.cpp
@@ -661,12 +661,12 @@ Try<vector<Resource>> Resources::fromSimpleString(
 
     string name;
     string role;
-    size_t openParen = pair[0].find("(");
+    size_t openParen = pair[0].find('(');
     if (openParen == string::npos) {
       name = strings::trim(pair[0]);
       role = defaultRole;
     } else {
-      size_t closeParen = pair[0].find(")");
+      size_t closeParen = pair[0].find(')');
       if (closeParen == string::npos || closeParen < openParen) {
         return Error(
             "Bad value for resources, mismatched parentheses in " + token);

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/docker/docker.cpp
----------------------------------------------------------------------
diff --git a/src/docker/docker.cpp b/src/docker/docker.cpp
index 472cb1b..b63b060 100755
--- a/src/docker/docker.cpp
+++ b/src/docker/docker.cpp
@@ -532,7 +532,7 @@ Future<Option<int>> Docker::run(
     }
   }
 
-  string environmentVariables = "";
+  string environmentVariables;
 
   if (env.isSome()) {
     foreachpair (const string& key, const string& value, env.get()) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/slave/containerizer/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/fetcher.cpp b/src/slave/containerizer/fetcher.cpp
index 94cfa0e..ba2e118 100644
--- a/src/slave/containerizer/fetcher.cpp
+++ b/src/slave/containerizer/fetcher.cpp
@@ -133,11 +133,11 @@ Try<string> Fetcher::basename(const string& uri)
     // ftp://, ftps://, hdfs://, hftp://, s3://, s3n://.
 
     string path = uri.substr(index + 3);
-    if (!strings::contains(path, "/") || path.size() <= path.find("/") + 1) {
+    if (!strings::contains(path, "/") || path.size() <= path.find('/') + 1) {
       return Error("Malformed URI (missing path): " + uri);
     }
 
-    return path.substr(path.find_last_of("/") + 1);
+    return path.substr(path.find_last_of('/') + 1);
   }
   return Path(uri).basename();
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/state/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/state/zookeeper.cpp b/src/state/zookeeper.cpp
index 9941f6b..1abd816 100644
--- a/src/state/zookeeper.cpp
+++ b/src/state/zookeeper.cpp
@@ -502,11 +502,11 @@ Result<bool> ZooKeeperStorageProcess::doSet(const Entry& entry,
   if (code == ZNONODE) {
     // Create directory path znodes as necessary.
     CHECK(znode.size() == 0 || znode.at(znode.size() - 1) != '/');
-    size_t index = znode.find("/", 0);
+    size_t index = znode.find('/', 0);
 
     while (index < string::npos) {
       // Get out the prefix to create.
-      index = znode.find("/", index + 1);
+      index = znode.find('/', index + 1);
       string prefix = znode.substr(0, index);
 
       // Create the znode (even if it already exists).

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/tests/environment.cpp
----------------------------------------------------------------------
diff --git a/src/tests/environment.cpp b/src/tests/environment.cpp
index a683d8c..6fe26e5 100644
--- a/src/tests/environment.cpp
+++ b/src/tests/environment.cpp
@@ -801,7 +801,7 @@ void Environment::SetUp()
     string variable = env[i];
     if (variable.find("MESOS_") == 0) {
       string key;
-      size_t eq = variable.find_first_of("=");
+      size_t eq = variable.find_first_of('=');
       if (eq == string::npos) {
         continue; // Not expecting a missing '=', but ignore anyway.
       }

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/v1/resources.cpp
----------------------------------------------------------------------
diff --git a/src/v1/resources.cpp b/src/v1/resources.cpp
index 859f738..da4701c 100644
--- a/src/v1/resources.cpp
+++ b/src/v1/resources.cpp
@@ -661,12 +661,12 @@ Try<vector<Resource>> Resources::fromSimpleString(
 
     string name;
     string role;
-    size_t openParen = pair[0].find("(");
+    size_t openParen = pair[0].find('(');
     if (openParen == string::npos) {
       name = strings::trim(pair[0]);
       role = defaultRole;
     } else {
-      size_t closeParen = pair[0].find(")");
+      size_t closeParen = pair[0].find(')');
       if (closeParen == string::npos || closeParen < openParen) {
         return Error(
             "Bad value for resources, mismatched parentheses in " + token);

http://git-wip-us.apache.org/repos/asf/mesos/blob/c0aee8cc/src/zookeeper/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/zookeeper/zookeeper.cpp b/src/zookeeper/zookeeper.cpp
index e105377..5ede4e5 100644
--- a/src/zookeeper/zookeeper.cpp
+++ b/src/zookeeper/zookeeper.cpp
@@ -260,7 +260,7 @@ public:
     // because, it doesn't return the expected path when a path ends
     // with "/". For example, to create path "/a/b/", we want to
     // recursively create "/a/b", instead of just creating "/a".
-    const string& parent = path.substr(0, path.find_last_of("/"));
+    const string& parent = path.substr(0, path.find_last_of('/'));
     if (!parent.empty()) {
       return create(parent, "", acl, 0, result, true)
         .then(defer(self(),