You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/07/28 22:54:33 UTC

mesos git commit: Used size_t as the type of size, count and index variables.

Repository: mesos
Updated Branches:
  refs/heads/master e904c9e44 -> bf5b0b252


Used size_t as the type of size, count and index variables.

We should use size_t as the type of size, count and index variables
in general, as it provides additional information to the reader.

Note that for many STL containers use size_t as the size_type.

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


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

Branch: refs/heads/master
Commit: bf5b0b2523e5270dce57613ae99fffb5c24e5fa6
Parents: e904c9e
Author: Guangya Liu <gy...@gmail.com>
Authored: Thu Jul 28 15:50:22 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Thu Jul 28 15:50:22 2016 -0700

----------------------------------------------------------------------
 .../mesos/isolators/gpu/allocator.cpp           |  2 +-
 src/tests/containerizer/port_mapping_tests.cpp  |  6 +++---
 src/tests/hierarchical_allocator_tests.cpp      | 20 ++++++++++----------
 3 files changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/bf5b0b25/src/slave/containerizer/mesos/isolators/gpu/allocator.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/gpu/allocator.cpp b/src/slave/containerizer/mesos/isolators/gpu/allocator.cpp
index 769dfa2..c1a87e9 100644
--- a/src/slave/containerizer/mesos/isolators/gpu/allocator.cpp
+++ b/src/slave/containerizer/mesos/isolators/gpu/allocator.cpp
@@ -85,7 +85,7 @@ static Try<set<Gpu>> enumerateGpus(
   if (flags.nvidia_gpu_devices.isSome()) {
     indices = flags.nvidia_gpu_devices.get();
   } else {
-    for (unsigned int i = 0; i < resources.gpus().getOrElse(0); ++i) {
+    for (size_t i = 0; i < resources.gpus().getOrElse(0); ++i) {
       indices.push_back(i);
     }
   }

http://git-wip-us.apache.org/repos/asf/mesos/blob/bf5b0b25/src/tests/containerizer/port_mapping_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/port_mapping_tests.cpp b/src/tests/containerizer/port_mapping_tests.cpp
index 3675c02..94d6d75 100644
--- a/src/tests/containerizer/port_mapping_tests.cpp
+++ b/src/tests/containerizer/port_mapping_tests.cpp
@@ -1049,7 +1049,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerICMPExternal)
   ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
 
   ostringstream command;
-  for (unsigned int i = 0; i < nameServers.size(); i++) {
+  for (size_t i = 0; i < nameServers.size(); i++) {
     const string& IP = nameServers[i];
     command << "ping -c1 " << IP;
     if (i + 1 < nameServers.size()) {
@@ -1226,7 +1226,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_ContainerARPExternal)
   ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
 
   ostringstream command;
-  for (unsigned int i = 0; i < nameServers.size(); i++) {
+  for (size_t i = 0; i < nameServers.size(); i++) {
     const string& IP = nameServers[i];
     // Time out after 1s and terminate upon receiving the first reply.
     command << "arping -f -w1 " << IP << " -I " << eth0;
@@ -1322,7 +1322,7 @@ TEST_F(PortMappingIsolatorTest, ROOT_DNS)
   ASSERT_EQ(1, launchInfo.get()->pre_exec_commands().size());
 
   ostringstream command;
-  for (unsigned int i = 0; i < nameServers.size(); i++) {
+  for (size_t i = 0; i < nameServers.size(); i++) {
     const string& IP = nameServers[i];
     command << "host " << IP;
     if (i + 1 < nameServers.size()) {

http://git-wip-us.apache.org/repos/asf/mesos/blob/bf5b0b25/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index bb6947f..33f5a42 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -3097,7 +3097,7 @@ TEST_F(HierarchicalAllocatorTest, UpdateWeight)
 
   // Register six agents with the same resources (cpus:2;mem:1024).
   vector<SlaveInfo> agents;
-  for (unsigned i = 0; i < 6; i++) {
+  for (size_t i = 0; i < 6; i++) {
     SlaveInfo agent = createSlaveInfo(SINGLE_RESOURCE);
     agents.push_back(agent);
     allocator->addSlave(agent.id(), agent, None(), agent.resources(), {});
@@ -3348,12 +3348,12 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
   vector<FrameworkInfo> frameworks;
   frameworks.reserve(frameworkCount);
 
-  for (unsigned i = 0; i < slaveCount; i++) {
+  for (size_t i = 0; i < slaveCount; i++) {
     slaves.push_back(createSlaveInfo(
         "cpus:2;mem:1024;disk:4096;ports:[31000-32000]"));
   }
 
-  for (unsigned i = 0; i < frameworkCount; i++) {
+  for (size_t i = 0; i < frameworkCount; i++) {
     frameworks.push_back(createFrameworkInfo(
         "*",
         {FrameworkInfo::Capability::REVOCABLE_RESOURCES}));
@@ -3397,7 +3397,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, AddAndUpdateSlave)
 
   // Add the slaves, use round-robin to choose which framework
   // to allocate a slice of the slave's resources to.
-  for (unsigned i = 0; i < slaves.size(); i++) {
+  for (size_t i = 0; i < slaves.size(); i++) {
     hashmap<FrameworkID, Resources> used;
 
     used[frameworks[i % frameworkCount].id()] = slaveResources;
@@ -3490,7 +3490,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, DeclineOffers)
   Stopwatch watch;
   watch.start();
 
-  for (unsigned i = 0; i < frameworkCount; i++) {
+  for (size_t i = 0; i < frameworkCount; i++) {
     frameworks.push_back(createFrameworkInfo("*"));
     allocator->addFramework(frameworks[i].id(), frameworks[i], {});
   }
@@ -3514,7 +3514,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, DeclineOffers)
 
   watch.start();
 
-  for (unsigned i = 0; i < slaveCount; i++) {
+  for (size_t i = 0; i < slaveCount; i++) {
     slaves.push_back(createSlaveInfo(
         "cpus:24;mem:4096;disk:4096;ports:[31000-32000]"));
 
@@ -3535,7 +3535,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, DeclineOffers)
        << watch.elapsed() << endl;
 
   // Loop enough times for all the frameworks to get offered all the resources.
-  for (unsigned i = 0; i < frameworkCount * 2; i++) {
+  for (size_t i = 0; i < frameworkCount * 2; i++) {
     // Permanently decline any offered resources.
     foreach (auto offer, offers) {
       Filters filters;
@@ -3632,7 +3632,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, ResourceLabels)
   Stopwatch watch;
   watch.start();
 
-  for (unsigned i = 0; i < frameworkCount; i++) {
+  for (size_t i = 0; i < frameworkCount; i++) {
     frameworks.push_back(createFrameworkInfo("role1"));
     allocator->addFramework(frameworks[i].id(), frameworks[i], {});
   }
@@ -3662,7 +3662,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, ResourceLabels)
 
   watch.start();
 
-  for (unsigned i = 0; i < slaveCount; i++) {
+  for (size_t i = 0; i < slaveCount; i++) {
     slaves.push_back(createSlaveInfo(
         "cpus:24;mem:4096;disk:4096;ports:[31000-32000]"));
 
@@ -3715,7 +3715,7 @@ TEST_P(HierarchicalAllocator_BENCHMARK_Test, ResourceLabels)
        << watch.elapsed() << endl;
 
   // Loop enough times for all the frameworks to get offered all the resources.
-  for (unsigned i = 0; i < frameworkCount * 2; i++) {
+  for (size_t i = 0; i < frameworkCount * 2; i++) {
     // Permanently decline any offered resources.
     foreach (auto offer, offers) {
       Filters filters;