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:42 UTC
[03/10] mesos git commit: Fixed conversion warnings.
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);