You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/01/12 17:32:40 UTC

[01/10] mesos git commit: Changed `Sorter::count()` to return `size_t` instead of `int`.

Repository: mesos
Updated Branches:
  refs/heads/master ccc5051a1 -> 93ab49409


Changed `Sorter::count()` to return `size_t` instead of `int`.

Also applies to `DRFSorter::count()`. The implementations return
`hashmap::count()` which is a `size_t`. Converting `size_t` to `int`
implicitly generates a "possible loss of data" warning.

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


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

Branch: refs/heads/master
Commit: 177a2221496a2caa5ad25e71c9982ca3eed02fd4
Parents: ac84a88
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Dec 13 15:59:30 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:16 2018 -0800

----------------------------------------------------------------------
 src/master/allocator/sorter/drf/sorter.cpp | 2 +-
 src/master/allocator/sorter/drf/sorter.hpp | 2 +-
 src/master/allocator/sorter/sorter.hpp     | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/177a2221/src/master/allocator/sorter/drf/sorter.cpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.cpp b/src/master/allocator/sorter/drf/sorter.cpp
index ecc5586..755a36e 100644
--- a/src/master/allocator/sorter/drf/sorter.cpp
+++ b/src/master/allocator/sorter/drf/sorter.cpp
@@ -584,7 +584,7 @@ bool DRFSorter::contains(const string& clientPath) const
 }
 
 
-int DRFSorter::count() const
+size_t DRFSorter::count() const
 {
   return clients.size();
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/177a2221/src/master/allocator/sorter/drf/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/drf/sorter.hpp b/src/master/allocator/sorter/drf/sorter.hpp
index 1a7681c..8a26854 100644
--- a/src/master/allocator/sorter/drf/sorter.hpp
+++ b/src/master/allocator/sorter/drf/sorter.hpp
@@ -103,7 +103,7 @@ public:
 
   virtual bool contains(const std::string& clientPath) const;
 
-  virtual int count() const;
+  virtual size_t count() const;
 
 private:
   // A node in the sorter's tree.

http://git-wip-us.apache.org/repos/asf/mesos/blob/177a2221/src/master/allocator/sorter/sorter.hpp
----------------------------------------------------------------------
diff --git a/src/master/allocator/sorter/sorter.hpp b/src/master/allocator/sorter/sorter.hpp
index 2c6e162..e5e8651 100644
--- a/src/master/allocator/sorter/sorter.hpp
+++ b/src/master/allocator/sorter/sorter.hpp
@@ -145,7 +145,7 @@ public:
 
   // Returns the number of clients this Sorter contains,
   // either active or inactive.
-  virtual int count() const = 0;
+  virtual size_t count() const = 0;
 };
 
 } // namespace allocator {


[07/10] mesos git commit: Ended `IOSwitchboard::_prepare` with `UNREACHABLE`.

Posted by an...@apache.org.
Ended `IOSwitchboard::_prepare` with `UNREACHABLE`.

All paths should `return`, but the compiler wasn't able to determine
this.

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


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

Branch: refs/heads/master
Commit: 9db0415007722d45c4ab7539a454b70ba955bfc0
Parents: 177a222
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Dec 12 16:02:30 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 src/slave/containerizer/mesos/io/switchboard.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9db04150/src/slave/containerizer/mesos/io/switchboard.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp b/src/slave/containerizer/mesos/io/switchboard.cpp
index 89dd498..777918a 100644
--- a/src/slave/containerizer/mesos/io/switchboard.cpp
+++ b/src/slave/containerizer/mesos/io/switchboard.cpp
@@ -320,7 +320,12 @@ Future<Option<ContainerLaunchInfo>> IOSwitchboard::_prepare(
     return ContainerLaunchInfo();
   }
 
-#ifndef __WINDOWS__
+#ifdef __WINDOWS__
+  // NOTE: On Windows, both return values of
+  // `IOSwitchboard::requiresServer(containerConfig)` are checked and will
+  // return before reaching here.
+  UNREACHABLE();
+#else
   // First make sure that we haven't already spawned an io
   // switchboard server for this container.
   if (infos.contains(containerId)) {


[08/10] mesos git commit: Fixed conversion warnings.

Posted by an...@apache.org.
Fixed conversion warnings.

Just casting to the used type.

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


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

Branch: refs/heads/master
Commit: c79412cd29c50c1f2d562f6c081f818d39f1f2d2
Parents: 65f06d3
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Dec 19 16:30:06 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

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


http://git-wip-us.apache.org/repos/asf/mesos/blob/c79412cd/3rdparty/libprocess/src/http.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/http.cpp b/3rdparty/libprocess/src/http.cpp
index f51d2aa..cc41fa6 100644
--- a/3rdparty/libprocess/src/http.cpp
+++ b/3rdparty/libprocess/src/http.cpp
@@ -2166,7 +2166,7 @@ Try<Server> Server::create(
   // tests that try and start making connections immediately after
   // `Server::run` has returned but potentially before
   // `Socket::listen` has been invoked.
-  Try<Nothing> listen = socket.listen(options.backlog);
+  Try<Nothing> listen = socket.listen(static_cast<int>(options.backlog));
   if (listen.isError()) {
     return Error("Failed to listen on socket: " + listen.error());
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/c79412cd/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 9d7a556..2126c27 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -407,7 +407,8 @@ public:
 
   long workers() const
   {
-    return threads.size() - 1; // Less 1 for event loop thread.
+    // Less 1 for event loop thread.
+    return static_cast<long>(threads.size() - 1);
   }
 
 private:


[02/10] mesos git commit: Templated operator overloads of `Duration`.

Posted by an...@apache.org.
Templated operator overloads of `Duration`.

Without this change, every use of `Duration * 2` throws a conversion
warning because we multiply `Duration` by `int` and `size_t` without
casting to `double`, and the operator overloads were all accepting only
doubles.

By templating them on `typename T`, we gain two benefits: no conversion
warnings are emitted because an `int64_t` can be safely multiplied by
any arithemetic type without casting, and when multiplying by integral
types, we are no longer subject to potential FPE introduced by casting
to a `double`. It is safe to simply template on `typename T` without
checking if it is an arithmetic type, as the compiler will only generate
a template if `double nanos * T multiplier` is valid.

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


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

Branch: refs/heads/master
Commit: ac84a883db62a452db1a80b0f15c81d73a14a68e
Parents: ccc5051
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Dec 14 18:09:33 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:16 2018 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/duration.hpp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ac84a883/3rdparty/stout/include/stout/duration.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/duration.hpp b/3rdparty/stout/include/stout/duration.hpp
index d10b6a4..930e481 100644
--- a/3rdparty/stout/include/stout/duration.hpp
+++ b/3rdparty/stout/include/stout/duration.hpp
@@ -135,13 +135,15 @@ public:
     return *this;
   }
 
-  Duration& operator*=(double multiplier)
+  template <typename T>
+  Duration& operator*=(T multiplier)
   {
     nanos = static_cast<int64_t>(nanos * multiplier);
     return *this;
   }
 
-  Duration& operator/=(double divisor)
+  template <typename T>
+  Duration& operator/=(T divisor)
   {
     nanos = static_cast<int64_t>(nanos / divisor);
     return *this;
@@ -161,14 +163,16 @@ public:
     return diff;
   }
 
-  Duration operator*(double multiplier) const
+  template <typename T>
+  Duration operator*(T multiplier) const
   {
     Duration product = *this;
     product *= multiplier;
     return product;
   }
 
-  Duration operator/(double divisor) const
+  template <typename T>
+  Duration operator/(T divisor) const
   {
     Duration quotient = *this;
     quotient /= divisor;


[06/10] mesos git commit: Fixed conversion warnings in tests.

Posted by an...@apache.org.
Fixed conversion warnings in tests.

Stringified a `size_t` for `http::Request.headers` value.

The types in `metrics_tests.cpp` were defined as `double`, and so should
be compared with `EXPECT_DOUBLE_EQ`, not `EXPECT_FLOAT_EQ`.

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


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

Branch: refs/heads/master
Commit: 65f06d36ad1701e70f541f42b8a32961e471ff15
Parents: 67d4247
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Dec 12 16:16:29 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 3rdparty/libprocess/src/tests/http_tests.cpp    |  2 +-
 3rdparty/libprocess/src/tests/metrics_tests.cpp | 32 ++++++++++----------
 2 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/65f06d36/3rdparty/libprocess/src/tests/http_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp
index 9daac71..f79d366 100644
--- a/3rdparty/libprocess/src/tests/http_tests.cpp
+++ b/3rdparty/libprocess/src/tests/http_tests.cpp
@@ -997,7 +997,7 @@ TEST(HTTPConnectionTest, GzipRequestBody)
   request.keepAlive = true;
 
   request.headers["Content-Encoding"] = "gzip";
-  request.headers["Content-Length"] = request.body.length();
+  request.headers["Content-Length"] = stringify(request.body.length());
 
   Future<http::Response> response = connection.send(request);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/65f06d36/3rdparty/libprocess/src/tests/metrics_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/tests/metrics_tests.cpp b/3rdparty/libprocess/src/tests/metrics_tests.cpp
index 5f7117e..5a5a2e5 100644
--- a/3rdparty/libprocess/src/tests/metrics_tests.cpp
+++ b/3rdparty/libprocess/src/tests/metrics_tests.cpp
@@ -192,15 +192,15 @@ TEST_F(MetricsTest, Statistics)
 
   EXPECT_EQ(11u, statistics.get().count);
 
-  EXPECT_FLOAT_EQ(0.0, statistics.get().min);
-  EXPECT_FLOAT_EQ(10.0, statistics.get().max);
+  EXPECT_DOUBLE_EQ(0.0, statistics.get().min);
+  EXPECT_DOUBLE_EQ(10.0, statistics.get().max);
 
-  EXPECT_FLOAT_EQ(5.0, statistics.get().p50);
-  EXPECT_FLOAT_EQ(9.0, statistics.get().p90);
-  EXPECT_FLOAT_EQ(9.5, statistics.get().p95);
-  EXPECT_FLOAT_EQ(9.9, statistics.get().p99);
-  EXPECT_FLOAT_EQ(9.99, statistics.get().p999);
-  EXPECT_FLOAT_EQ(9.999, statistics.get().p9999);
+  EXPECT_DOUBLE_EQ(5.0, statistics.get().p50);
+  EXPECT_DOUBLE_EQ(9.0, statistics.get().p90);
+  EXPECT_DOUBLE_EQ(9.5, statistics.get().p95);
+  EXPECT_DOUBLE_EQ(9.9, statistics.get().p99);
+  EXPECT_DOUBLE_EQ(9.99, statistics.get().p999);
+  EXPECT_DOUBLE_EQ(9.999, statistics.get().p9999);
 
   AWAIT_READY(metrics::remove(counter));
 }
@@ -242,13 +242,13 @@ TEST_F(MetricsTest, THREADSAFE_Snapshot)
   map<string, JSON::Value> values = responseJSON.get().values;
 
   EXPECT_EQ(1u, values.count("test/counter"));
-  EXPECT_FLOAT_EQ(0.0, values["test/counter"].as<JSON::Number>().as<double>());
+  EXPECT_DOUBLE_EQ(0.0, values["test/counter"].as<JSON::Number>().as<double>());
 
   EXPECT_EQ(1u, values.count("test/gauge"));
-  EXPECT_FLOAT_EQ(42.0, values["test/gauge"].as<JSON::Number>().as<double>());
+  EXPECT_DOUBLE_EQ(42.0, values["test/gauge"].as<JSON::Number>().as<double>());
 
   EXPECT_EQ(1u, values.count("test/gauge_const"));
-  EXPECT_FLOAT_EQ(
+  EXPECT_DOUBLE_EQ(
       99.0, values["test/gauge_const"].as<JSON::Number>().as<double>());
 
   EXPECT_EQ(0u, values.count("test/gauge_fail"));
@@ -397,10 +397,10 @@ TEST_F(MetricsTest, THREADSAFE_SnapshotTimeout)
   map<string, JSON::Value> values = responseJSON.get().values;
 
   EXPECT_EQ(1u, values.count("test/counter"));
-  EXPECT_FLOAT_EQ(0.0, values["test/counter"].as<JSON::Number>().as<double>());
+  EXPECT_DOUBLE_EQ(0.0, values["test/counter"].as<JSON::Number>().as<double>());
 
   EXPECT_EQ(1u, values.count("test/gauge"));
-  EXPECT_FLOAT_EQ(42.0, values["test/gauge"].as<JSON::Number>().as<double>());
+  EXPECT_DOUBLE_EQ(42.0, values["test/gauge"].as<JSON::Number>().as<double>());
 
   EXPECT_EQ(0u, values.count("test/gauge_fail"));
   EXPECT_EQ(0u, values.count("test/gauge_timeout"));
@@ -497,7 +497,7 @@ TEST_F(MetricsTest, SnapshotStatistics)
   // Ensure the expected keys are in the response and that the values match
   // expectations.
   foreachkey (const string& key, expected) {
-    EXPECT_FLOAT_EQ(expected[key], responseValues[key]);
+    EXPECT_DOUBLE_EQ(expected[key], responseValues[key]);
   }
 
   AWAIT_READY(metrics::remove(counter));
@@ -522,7 +522,7 @@ TEST_F(MetricsTest, Timer)
 
   Future<double> value = timer.value();
   AWAIT_READY(value);
-  EXPECT_FLOAT_EQ(value.get(), Microseconds(1).ns());
+  EXPECT_DOUBLE_EQ(value.get(), static_cast<double>(Microseconds(1).ns()));
 
   // It is not an error to stop a timer that has already been stopped.
   timer.stop();
@@ -558,7 +558,7 @@ TEST_F(MetricsTest, AsyncTimer)
 
   // The future should have taken zero time.
   AWAIT_READY(t.value());
-  EXPECT_FLOAT_EQ(t.value().get(), 0.0);
+  EXPECT_DOUBLE_EQ(t.value().get(), 0.0);
 
   AWAIT_READY(metrics::remove(t));
 }


[03/10] mesos git commit: Fixed conversion warnings.

Posted by an...@apache.org.
Fixed conversion warnings.

Fixed conversion warnings in `cram_md5` authentication. The potential
for overflow here is exceedingly unlikely, and we have been ignoring
these warnings to date without problem.

Fixed conversion warning in `files.cpp`. The signature accepts an
`off_t` type, but we calculated the offset from a `size_t`.

Fixed `size_t` to `int` warning in `default_executor.cpp`. The only use
of this counter is in `taskGroup.tasks().Get(index++)`, which expects an
`int`, so we changed the type.

Fixed conversion warnings in master. We can't change the return types
because the `Metric` class only accepts `double` types, so we
`static_cast` (as we were already doing elsewhere in the class).

Fixed warnings when converting to `pid_t` in the containerizer. Can't
change the arguments types because they're in the protocol, but they
obviously represent a `pid_t` originally, so this is a safe
`static_cast`.

Fixed warnings when constructing a `Seconds` in `slave.cpp` as it takes
`int64_t`, but we're giving it a `double`. We can't change the `double`
because it's set in the protocol, and we're currently ignoring the
conversion anyway, so we just cast. We may want to provide a `double`
constructor for `Seconds` in the future that does proper rounding.

Fixed `size_t` to `int` conversion warning in `slave.cpp`. This counter
was only used in `usage->mutable_executors(i++)` which expected an
`int`, so we changed the type.

Fixed conversion warnings in `zookeeper.cpp`. The signatures of these
functions take an `int`, and they're coming from a `size()`. We have
bigger problems if this overflows.

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


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

Branch: refs/heads/master
Commit: 12be4ba002f2f5ff314fbc16af51d095b0d90e56
Parents: 0597b3c
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Dec 14 18:11:17 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 src/authentication/cram_md5/authenticatee.cpp           | 6 +++---
 src/authentication/cram_md5/authenticator.cpp           | 6 +++---
 src/files/files.cpp                                     | 2 +-
 src/launcher/default_executor.cpp                       | 2 +-
 src/launcher/executor.cpp                               | 2 +-
 src/master/master.cpp                                   | 2 +-
 src/master/master.hpp                                   | 2 +-
 src/master/registrar.cpp                                | 2 +-
 src/slave/containerizer/mesos/containerizer.cpp         | 2 +-
 src/slave/containerizer/mesos/isolators/posix.hpp       | 2 +-
 src/slave/containerizer/mesos/isolators/windows/cpu.cpp | 2 +-
 src/slave/containerizer/mesos/isolators/windows/mem.cpp | 2 +-
 src/slave/containerizer/mesos/launcher.cpp              | 2 +-
 src/slave/slave.cpp                                     | 8 +++++---
 src/zookeeper/zookeeper.cpp                             | 6 +++---
 15 files changed, 25 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/authentication/cram_md5/authenticatee.cpp
----------------------------------------------------------------------
diff --git a/src/authentication/cram_md5/authenticatee.cpp b/src/authentication/cram_md5/authenticatee.cpp
index 7b3f767..d43dedf 100644
--- a/src/authentication/cram_md5/authenticatee.cpp
+++ b/src/authentication/cram_md5/authenticatee.cpp
@@ -72,7 +72,7 @@ public:
     CHECK(secret != nullptr) << "Failed to allocate memory for secret";
 
     memcpy(secret->data, data, length);
-    secret->len = length;
+    secret->len = static_cast<unsigned long>(length);
   }
 
   virtual ~CRAMMD5AuthenticateeProcess()
@@ -265,7 +265,7 @@ protected:
     int result = sasl_client_step(
         connection,
         data.length() == 0 ? nullptr : data.data(),
-        data.length(),
+        static_cast<unsigned>(data.length()),
         &interact,
         &output,
         &length);
@@ -330,7 +330,7 @@ private:
     CHECK(SASL_CB_USER == id || SASL_CB_AUTHNAME == id);
     *result = static_cast<const char*>(context);
     if (length != nullptr) {
-      *length = strlen(*result);
+      *length = static_cast<unsigned>(strlen(*result));
     }
     return SASL_OK;
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/authentication/cram_md5/authenticator.cpp
----------------------------------------------------------------------
diff --git a/src/authentication/cram_md5/authenticator.cpp b/src/authentication/cram_md5/authenticator.cpp
index 2a12bb3..0aad3aa 100644
--- a/src/authentication/cram_md5/authenticator.cpp
+++ b/src/authentication/cram_md5/authenticator.cpp
@@ -211,7 +211,7 @@ public:
         connection,
         mechanism.c_str(),
         data.length() == 0 ? nullptr : data.data(),
-        data.length(),
+        static_cast<unsigned>(data.length()),
         &output,
         &length);
 
@@ -237,7 +237,7 @@ public:
     int result = sasl_server_step(
         connection,
         data.length() == 0 ? nullptr : data.data(),
-        data.length(),
+        static_cast<unsigned>(data.length()),
         &output,
         &length);
 
@@ -271,7 +271,7 @@ private:
     }
 
     if (found && length != nullptr) {
-      *length = strlen(*result);
+      *length = static_cast<unsigned>(strlen(*result));
     }
 
     return SASL_OK;

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index ad2189b..324b4bc 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -701,7 +701,7 @@ Future<Try<tuple<size_t, string>, FilesError>> FilesProcess::_read(
   length = std::min(length.get(), os::pagesize() * 16);
 
   // Seek to the offset we want to read from.
-  lseek = os::lseek(fd.get(), offset, SEEK_SET);
+  lseek = os::lseek(fd.get(), static_cast<off_t>(offset), SEEK_SET);
   if (lseek.isError()) {
     string error = strings::format(
         "Failed to seek file at '%s': %s",

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/launcher/default_executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/default_executor.cpp b/src/launcher/default_executor.cpp
index 6c88de4..4a61985 100644
--- a/src/launcher/default_executor.cpp
+++ b/src/launcher/default_executor.cpp
@@ -547,7 +547,7 @@ protected:
     CHECK(launched);
     CHECK_EQ(containerIds.size(), (size_t) taskGroup.tasks().size());
 
-    size_t index = 0;
+    int index = 0;
     foreach (const ContainerID& containerId, containerIds) {
       const TaskInfo& task = taskGroup.tasks().Get(index++);
       const TaskID& taskId = task.task_id();

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/launcher/executor.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/executor.cpp b/src/launcher/executor.cpp
index 794bf7c..050f5a0 100644
--- a/src/launcher/executor.cpp
+++ b/src/launcher/executor.cpp
@@ -858,7 +858,7 @@ private:
       }
 
       // Now perform signal escalation to begin killing the task.
-      CHECK_GT(pid, 0);
+      CHECK_GT(pid, static_cast<pid_t>(0));
 
       LOG(INFO) << "Sending SIGTERM to process tree at pid " << pid;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 8921964..c96cd70 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -10815,7 +10815,7 @@ double Master::_slaves_inactive()
 
 double Master::_slaves_unreachable()
 {
-  return slaves.unreachable.size();
+  return static_cast<double>(slaves.unreachable.size());
 }
 
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/master/master.hpp
----------------------------------------------------------------------
diff --git a/src/master/master.hpp b/src/master/master.hpp
index cdfd06c..f915c6f 100644
--- a/src/master/master.hpp
+++ b/src/master/master.hpp
@@ -2087,7 +2087,7 @@ private:
 
   double _outstanding_offers()
   {
-    return offers.size();
+    return static_cast<double>(offers.size());
   }
 
   double _event_queue_messages()

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/master/registrar.cpp
----------------------------------------------------------------------
diff --git a/src/master/registrar.cpp b/src/master/registrar.cpp
index ffb4582..aabce22 100644
--- a/src/master/registrar.cpp
+++ b/src/master/registrar.cpp
@@ -184,7 +184,7 @@ private:
   // Gauge handlers.
   double _queued_operations()
   {
-    return operations.size();
+    return static_cast<double>(operations.size());
   }
 
   Future<double> _registry_size_bytes()

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index cddc617..ec39d04 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -763,7 +763,7 @@ Future<Nothing> MesosContainerizerProcess::recover(
     // Contruct the structure for containers from the 'SlaveState'
     // first, to maintain the children list in the container.
     Owned<Container> container(new Container());
-    container->status = reap(containerId, state.pid());
+    container->status = reap(containerId, static_cast<pid_t>(state.pid()));
 
     // We only checkpoint the containerizer pid after the container
     // successfully launched, therefore we can assume checkpointed

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/slave/containerizer/mesos/isolators/posix.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/posix.hpp b/src/slave/containerizer/mesos/isolators/posix.hpp
index caa282c..f70a86c 100644
--- a/src/slave/containerizer/mesos/isolators/posix.hpp
+++ b/src/slave/containerizer/mesos/isolators/posix.hpp
@@ -52,7 +52,7 @@ public:
         return process::Failure("Container already recovered");
       }
 
-      pids.put(run.container_id(), run.pid());
+      pids.put(run.container_id(), static_cast<pid_t>(run.pid()));
 
       process::Owned<process::Promise<mesos::slave::ContainerLimitation>>
         promise(new process::Promise<mesos::slave::ContainerLimitation>());

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/slave/containerizer/mesos/isolators/windows/cpu.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/windows/cpu.cpp b/src/slave/containerizer/mesos/isolators/windows/cpu.cpp
index 6b376ef..69b0ff8 100644
--- a/src/slave/containerizer/mesos/isolators/windows/cpu.cpp
+++ b/src/slave/containerizer/mesos/isolators/windows/cpu.cpp
@@ -70,7 +70,7 @@ Future<Nothing> WindowsCpuIsolatorProcess::recover(
       return Failure("Container already recovered");
     }
 
-    infos[run.container_id()] = {run.pid(), None()};
+    infos[run.container_id()] = {static_cast<pid_t>(run.pid()), None()};
   }
 
   return Nothing();

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/slave/containerizer/mesos/isolators/windows/mem.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/windows/mem.cpp b/src/slave/containerizer/mesos/isolators/windows/mem.cpp
index 64d1134..6cc65b9 100644
--- a/src/slave/containerizer/mesos/isolators/windows/mem.cpp
+++ b/src/slave/containerizer/mesos/isolators/windows/mem.cpp
@@ -71,7 +71,7 @@ Future<Nothing> WindowsMemIsolatorProcess::recover(
       return Failure("Container already recovered");
     }
 
-    infos[run.container_id()] = {run.pid(), None()};
+    infos[run.container_id()] = {static_cast<pid_t>(run.pid()), None()};
   }
 
   return Nothing();

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/slave/containerizer/mesos/launcher.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launcher.cpp b/src/slave/containerizer/mesos/launcher.cpp
index ec31fa2..0e37cd2 100644
--- a/src/slave/containerizer/mesos/launcher.cpp
+++ b/src/slave/containerizer/mesos/launcher.cpp
@@ -60,7 +60,7 @@ Future<hashset<ContainerID>> SubprocessLauncher::recover(
 {
   foreach (const ContainerState& state, states) {
     const ContainerID& containerId = state.container_id();
-    pid_t pid = state.pid();
+    pid_t pid = static_cast<pid_t>(state.pid());
 
     if (pids.containsValue(pid)) {
       // This should (almost) never occur. There is the possibility

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index 0aa4e5e..5ad6410 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -1265,7 +1265,8 @@ void Slave::registered(
   CHECK_SOME(master);
 
   if (connection.has_total_ping_timeout_seconds()) {
-    masterPingTimeout = Seconds(connection.total_ping_timeout_seconds());
+    masterPingTimeout =
+      Seconds(static_cast<int64_t>(connection.total_ping_timeout_seconds()));
   } else {
     masterPingTimeout = DEFAULT_MASTER_PING_TIMEOUT();
   }
@@ -1368,7 +1369,8 @@ void Slave::reregistered(
   }
 
   if (connection.has_total_ping_timeout_seconds()) {
-    masterPingTimeout = Seconds(connection.total_ping_timeout_seconds());
+    masterPingTimeout =
+      Seconds(static_cast<int64_t>(connection.total_ping_timeout_seconds()));
   } else {
     masterPingTimeout = DEFAULT_MASTER_PING_TIMEOUT();
   }
@@ -7787,7 +7789,7 @@ Future<ResourceUsage> Slave::usage()
         // 'future' and 'executor' below should be in sync.
         CHECK_EQ(futures.size(), (size_t) usage->executors_size());
 
-        size_t i = 0;
+        int i = 0;
         foreach (const Future<ResourceStatistics>& future, futures) {
           ResourceUsage::Executor* executor = usage->mutable_executors(i++);
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/12be4ba0/src/zookeeper/zookeeper.cpp
----------------------------------------------------------------------
diff --git a/src/zookeeper/zookeeper.cpp b/src/zookeeper/zookeeper.cpp
index 5ede4e5..52c4af1 100644
--- a/src/zookeeper/zookeeper.cpp
+++ b/src/zookeeper/zookeeper.cpp
@@ -173,7 +173,7 @@ public:
         zh,
         scheme.c_str(),
         credentials.data(),
-        credentials.size(),
+        static_cast<int>(credentials.size()),
         voidCompletion,
         args);
 
@@ -204,7 +204,7 @@ public:
         zh,
         path.c_str(),
         data.data(),
-        data.size(),
+        static_cast<int>(data.size()),
         &acl,
         flags,
         stringCompletion,
@@ -391,7 +391,7 @@ public:
         zh,
         path.c_str(),
         data.data(),
-        data.size(),
+        static_cast<int>(data.size()),
         version,
         statCompletion,
         args);


[05/10] mesos git commit: Fixed conversion warnings in tests.

Posted by an...@apache.org.
Fixed conversion warnings in tests.

Fixed `double -> float` conversions. While the Protobuf type and literal
type are both `double`, the `FLOAT_EQ` tests were being used instead of
`DOUBLE_EQ`, causing a conversion warning.

Fixed `size_t` to `int` conversion warnings by casting.

Fixed warning for `Seconds(double)` as it takes `int64_t`. Can't change
the argument types because they're set in the protocol.

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


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

Branch: refs/heads/master
Commit: 0597b3c17d291cc56f5cd5b59f376d1d59b9a4ab
Parents: c79412c
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Dec 14 10:58:12 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 src/tests/attributes_tests.cpp      | 2 +-
 src/tests/protobuf_io_tests.cpp     | 8 +++++---
 src/tests/resource_offers_tests.cpp | 2 +-
 src/tests/resources_tests.cpp       | 8 ++++----
 src/tests/resources_utils.cpp       | 2 +-
 src/tests/scheduler_tests.cpp       | 4 ++--
 src/tests/slave_tests.cpp           | 4 +++-
 src/tests/values_tests.cpp          | 2 +-
 8 files changed, 18 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/attributes_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/attributes_tests.cpp b/src/tests/attributes_tests.cpp
index f053292..73e8930 100644
--- a/src/tests/attributes_tests.cpp
+++ b/src/tests/attributes_tests.cpp
@@ -32,7 +32,7 @@ TEST(AttributesTest, Parsing)
                                    "rack:rack1,rack2");
   ASSERT_EQ(Value::SCALAR, a.get(0).type());
   ASSERT_EQ("cpus", a.get(0).name());
-  ASSERT_FLOAT_EQ(45.55, a.get(0).scalar().value());
+  ASSERT_DOUBLE_EQ(45.55, a.get(0).scalar().value());
 
   ASSERT_EQ(Value::RANGES, a.get(1).type());
   ASSERT_EQ("ports", a.get(1).name());

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/protobuf_io_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/protobuf_io_tests.cpp b/src/tests/protobuf_io_tests.cpp
index ddbda03..4cdf17f 100644
--- a/src/tests/protobuf_io_tests.cpp
+++ b/src/tests/protobuf_io_tests.cpp
@@ -140,8 +140,10 @@ TEST_F(ProtobufIOTest, RepeatedPtrField)
 
   RepeatedPtrField<FrameworkID> expected;
 
-  const size_t size = 10;
-  for (size_t i = 0; i < size; i++) {
+  // NOTE: This uses `int` instead of `size_t` because eventually the iterator
+  // is used in `Get(int)`, and converting from `size_t` generates a warning.
+  const int size = 10;
+  for (int i = 0; i < size; i++) {
     FrameworkID frameworkId;
     frameworkId.set_value(stringify(i));
     expected.Add()->CopyFrom(frameworkId);
@@ -156,7 +158,7 @@ TEST_F(ProtobufIOTest, RepeatedPtrField)
   ASSERT_SOME(actual);
 
   ASSERT_EQ(expected.size(), actual->size());
-  for (size_t i = 0; i < size; i++) {
+  for (int i = 0; i < size; i++) {
     EXPECT_EQ(expected.Get(i), actual->Get(i));
   }
 }

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/resource_offers_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resource_offers_tests.cpp b/src/tests/resource_offers_tests.cpp
index 5564636..54aafdb 100644
--- a/src/tests/resource_offers_tests.cpp
+++ b/src/tests/resource_offers_tests.cpp
@@ -239,7 +239,7 @@ TEST_F(ResourceOffersTest, ResourcesGetReofferedAfterTaskInfoError)
   Resource* mem = task.add_resources();
   mem->set_name("mem");
   mem->set_type(Value::SCALAR);
-  mem->mutable_scalar()->set_value(Gigabytes(1).bytes());
+  mem->mutable_scalar()->set_value(static_cast<double>(Gigabytes(1).bytes()));
 
   vector<TaskInfo> tasks;
   tasks.push_back(task);

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/resources_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_tests.cpp b/src/tests/resources_tests.cpp
index bd328b2..d27bf53 100644
--- a/src/tests/resources_tests.cpp
+++ b/src/tests/resources_tests.cpp
@@ -67,7 +67,7 @@ TEST(ResourcesTest, Parsing)
   Resource cpus = Resources::parse("cpus", "45.55", "*").get();
 
   ASSERT_EQ(Value::SCALAR, cpus.type());
-  EXPECT_FLOAT_EQ(45.55, cpus.scalar().value());
+  EXPECT_DOUBLE_EQ(45.55, cpus.scalar().value());
 
   Resource ports = Resources::parse(
       "ports", "[10000-20000, 30000-50000]", "*").get();
@@ -776,7 +776,7 @@ TEST(ResourcesTest, Resources)
       "cpus:45.55;mem:1024;ports:[10000-20000, 30000-50000];disk:512").get();
 
   EXPECT_SOME(r.cpus());
-  EXPECT_FLOAT_EQ(45.55, r.cpus().get());
+  EXPECT_DOUBLE_EQ(45.55, r.cpus().get());
   EXPECT_SOME_EQ(Megabytes(1024), r.mem());
   EXPECT_SOME_EQ(Megabytes(512), r.disk());
 
@@ -790,7 +790,7 @@ TEST(ResourcesTest, Resources)
   r = Resources::parse("cpus:45.55;disk:512").get();
 
   EXPECT_SOME(r.cpus());
-  EXPECT_FLOAT_EQ(45.55, r.cpus().get());
+  EXPECT_DOUBLE_EQ(45.55, r.cpus().get());
   EXPECT_SOME_EQ(Megabytes(512), r.disk());
   EXPECT_TRUE(r.mem().isNone());
   EXPECT_TRUE(r.ports().isNone());
@@ -2612,7 +2612,7 @@ TEST(ResourcesOperationTest, StrippedResourcesVolume)
   Resource strippedVolume = *(stripped.begin());
 
   ASSERT_EQ(Value::SCALAR, strippedVolume.type());
-  EXPECT_FLOAT_EQ(200, strippedVolume.scalar().value());
+  EXPECT_DOUBLE_EQ(200, strippedVolume.scalar().value());
   EXPECT_EQ("role", Resources::reservationRole(strippedVolume));
   EXPECT_EQ("disk", strippedVolume.name());
   EXPECT_EQ(1, strippedVolume.reservations_size());

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/resources_utils.cpp
----------------------------------------------------------------------
diff --git a/src/tests/resources_utils.cpp b/src/tests/resources_utils.cpp
index 9736c2a..65d79ce 100644
--- a/src/tests/resources_utils.cpp
+++ b/src/tests/resources_utils.cpp
@@ -90,7 +90,7 @@ Try<::mesos::Value::Ranges> fragment(
   // We fragment from the front of the bounds until we have the
   // desired number of ranges.
   ::mesos::Value::Ranges ranges;
-  ranges.mutable_range()->Reserve(numRanges);
+  ranges.mutable_range()->Reserve(static_cast<int>(numRanges));
 
   for (size_t i = 0; i < numRanges; ++i) {
     Value::Range* range = ranges.add_range();

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/scheduler_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/scheduler_tests.cpp b/src/tests/scheduler_tests.cpp
index 87ef589..397a090 100644
--- a/src/tests/scheduler_tests.cpp
+++ b/src/tests/scheduler_tests.cpp
@@ -1996,7 +1996,7 @@ TEST_P(SchedulerReconcileTasks_BENCHMARK_Test, SchedulerLibrary)
   const size_t tasks = GetParam();
 
   EXPECT_CALL(*scheduler, update(_, _))
-    .Times(tasks);
+    .Times(static_cast<int>(tasks));
 
   Call call;
   call.mutable_framework_id()->CopyFrom(frameworkId);
@@ -2044,7 +2044,7 @@ TEST_P(SchedulerReconcileTasks_BENCHMARK_Test, SchedulerDriver)
   const size_t tasks = GetParam();
 
   EXPECT_CALL(sched, statusUpdate(&driver, _))
-    .Times(tasks);
+    .Times(static_cast<int>(tasks));
 
   vector<TaskStatus> statuses;
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/slave_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/slave_tests.cpp b/src/tests/slave_tests.cpp
index 288a419..59e3065 100644
--- a/src/tests/slave_tests.cpp
+++ b/src/tests/slave_tests.cpp
@@ -3320,7 +3320,9 @@ TEST_F(SlaveTest, PingTimeoutNoPings)
   AWAIT_READY(slaveRegisteredMessage);
   ASSERT_TRUE(slaveRegisteredMessage->has_connection());
   MasterSlaveConnection connection = slaveRegisteredMessage->connection();
-  EXPECT_EQ(totalTimeout, Seconds(connection.total_ping_timeout_seconds()));
+  EXPECT_EQ(
+      totalTimeout,
+      Seconds(static_cast<int64_t>(connection.total_ping_timeout_seconds())));
 
   // Ensure the slave processes the registration message and schedules
   // the ping timeout, before we advance the clock.

http://git-wip-us.apache.org/repos/asf/mesos/blob/0597b3c1/src/tests/values_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/values_tests.cpp b/src/tests/values_tests.cpp
index f7e6fa7..2f5abed 100644
--- a/src/tests/values_tests.cpp
+++ b/src/tests/values_tests.cpp
@@ -48,7 +48,7 @@ TEST(ValuesTest, ValidInput)
   Try<Value> result1 = parse("45.55");
   ASSERT_SOME(result1);
   ASSERT_EQ(Value::SCALAR, result1->type());
-  EXPECT_FLOAT_EQ(45.55, result1->scalar().value());
+  EXPECT_DOUBLE_EQ(45.55, result1->scalar().value());
 
   // Test parsing ranges type.
   Try<Value> result2 = parse("[10000-20000, 30000-50000]");


[04/10] mesos git commit: Fixed conversion warnings in tests.

Posted by an...@apache.org.
Fixed conversion warnings in tests.

The signature of `flags.load` takes an `int`, but
`arraySize` (correctly) returns a `size_t`. We don't want to change
`flags.load` to take a `size_t` because its signature is `int argc,
char** argv`, and so we may be sending it `int` in other places.

As all the test arrays are statically sized, we know that we're not
overflowing an `int`, so it is safe to just `static_cast<int>` here.

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


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

Branch: refs/heads/master
Commit: 67d42478578da3065c549a1e4b91b087586d45b4
Parents: 9db0415
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Tue Dec 12 10:08:25 2017 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 3rdparty/stout/tests/flags_tests.cpp      | 23 +++++++++++++++--------
 3rdparty/stout/tests/subcommand_tests.cpp |  2 +-
 2 files changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/67d42478/3rdparty/stout/tests/flags_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/flags_tests.cpp b/3rdparty/stout/tests/flags_tests.cpp
index 60ed8eb..d0591ed 100644
--- a/3rdparty/stout/tests/flags_tests.cpp
+++ b/3rdparty/stout/tests/flags_tests.cpp
@@ -268,8 +268,9 @@ TEST(FlagsTest, LoadFromCommandLine)
     "--no-name4",
     "--name5"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_SOME(load);
   EXPECT_TRUE(load->warnings.empty());
 
@@ -300,8 +301,9 @@ TEST(FlagsTest, LoadFromCommandLineWithNonFlags)
     "the",
     "end"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_SOME(load);
   EXPECT_TRUE(load->warnings.empty());
 
@@ -332,8 +334,9 @@ TEST(FlagsTest, LoadFromCommandLineWithDashDash)
     "--name5",
     "the"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_SOME(load);
   EXPECT_TRUE(load->warnings.empty());
 
@@ -362,7 +365,7 @@ TEST(FlagsTest, LoadFromCommandLineAndUpdateArgcArgv)
     (char*)"--name5",
     (char*)"the"
   };
-  int argc = arraySize(argv);
+  int argc = static_cast<int>(arraySize(argv));
 
   // Need a temporary since some compilers want to treat the type of
   // 'argv' as 'char *(*)[argc]' since the size of the array is known.
@@ -532,9 +535,10 @@ TEST(FlagsTest, DuplicatesFromEnvironment)
     "/path/to/program",
     "--name1=billy joel"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
   // `load(prefix, argc, argv)`.
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_SOME(load);
   EXPECT_TRUE(load->warnings.empty());
 
@@ -586,10 +590,11 @@ TEST(FlagsTest, DuplicatesFromCommandLine)
     "--name1=billy joel",
     "--name1=ben folds"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
   // TODO(klaus1982): Simply checking for the error. Once typed errors are
   // introduced, capture it within the type system.
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_ERROR(load);
 }
 
@@ -614,9 +619,10 @@ TEST(FlagsTest, AliasDuplicateFromCommandLine)
     "--name=billy joel",
     "--alias=ben folds"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
   // Loading the same flag with the name and alias should be an error.
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_ERROR(load);
 }
 
@@ -774,8 +780,9 @@ TEST(FlagsTest, Validate)
     "/path/to/program",
     "--duration=2hrs"
   };
+  const int argc = static_cast<int>(arraySize(argv));
 
-  Try<Warnings> load = flags.load("FLAGSTEST_", arraySize(argv), argv);
+  Try<Warnings> load = flags.load("FLAGSTEST_", argc, argv);
   EXPECT_ERROR(load);
 
   EXPECT_EQ("Expected --duration to be less than 1 hour", load.error());

http://git-wip-us.apache.org/repos/asf/mesos/blob/67d42478/3rdparty/stout/tests/subcommand_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/subcommand_tests.cpp b/3rdparty/stout/tests/subcommand_tests.cpp
index 54d70c9..211d28d 100644
--- a/3rdparty/stout/tests/subcommand_tests.cpp
+++ b/3rdparty/stout/tests/subcommand_tests.cpp
@@ -113,7 +113,7 @@ TEST(SubcommandTest, Flags)
 
   // Construct the command line arguments.
   vector<string> _argv = getArgv(flags);
-  int argc = _argv.size() + 2;
+  int argc = static_cast<int>(_argv.size()) + 2;
   char** argv = new char*[argc];
   argv[0] = (char*) "command";
   argv[1] = (char*) "subcommand";


[09/10] mesos git commit: Windows: Explicitly state source and destination path for extract.

Posted by an...@apache.org.
Windows: Explicitly state source and destination path for extract.

Makes it more clear that it is in the correct order.

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


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

Branch: refs/heads/master
Commit: 93ab49409e1a81679b50fd4f30f287bd4d4569a3
Parents: ff77d32
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Jan 4 14:57:49 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 src/launcher/fetcher.cpp | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/93ab4940/src/launcher/fetcher.cpp
----------------------------------------------------------------------
diff --git a/src/launcher/fetcher.cpp b/src/launcher/fetcher.cpp
index e2372a1..7fc69fe 100644
--- a/src/launcher/fetcher.cpp
+++ b/src/launcher/fetcher.cpp
@@ -97,7 +97,9 @@ static Try<bool> extract(
                "-Command",
                "Expand-Archive",
                "-Force",
+               "-Path",
                sourcePath,
+               "-DestinationPath",
                destinationDirectory};
 #else
     command = {"unzip", "-o", "-d", destinationDirectory, sourcePath};


[10/10] mesos git commit: Windows: Fixed memory leak.

Posted by an...@apache.org.
Windows: Fixed memory leak.

The environment strings variable block is allocated by the system, and
must be manually freed (according to the docs).

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


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

Branch: refs/heads/master
Commit: ff77d3235f5845192064b0f227918775ee035b01
Parents: 12be4ba
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Wed Jan 3 11:40:30 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Fri Jan 12 09:29:17 2018 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/windows/environment.hpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/ff77d323/3rdparty/stout/include/stout/os/windows/environment.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/environment.hpp b/3rdparty/stout/include/stout/os/windows/environment.hpp
index f79cbfa..40eee59 100644
--- a/3rdparty/stout/include/stout/os/windows/environment.hpp
+++ b/3rdparty/stout/include/stout/os/windows/environment.hpp
@@ -14,6 +14,7 @@
 #define __STOUT_OS_WINDOWS_ENVIRONMENT_HPP__
 
 #include <map>
+#include <memory>
 #include <string>
 #include <stout/stringify.hpp>
 
@@ -29,11 +30,13 @@ inline std::map<std::string, std::string> environment()
   // Var3=Value3\0
   // ...
   // VarN=ValueN\0\0
-  wchar_t* env = ::GetEnvironmentStringsW();
+  const std::unique_ptr<wchar_t[], decltype(&::FreeEnvironmentStringsW)> env(
+      ::GetEnvironmentStringsW(), &::FreeEnvironmentStringsW);
   std::map<std::string, std::string> result;
 
-  for (size_t i = 0; env[i] != L'\0' && env[i+1] != L'\0';) {
-    std::wstring entry(env + i);
+  for (size_t i = 0; env[i] != L'\0' && env[i+1] != L'\0';
+       /* incremented below */) {
+    std::wstring entry(&env[i]);
 
     // Increment past the current environment string and null terminator.
     i = i + entry.size() + 1;