]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/crush/CrushCompiler.cc
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / crush / CrushCompiler.cc
index ae9152de660ec6c4bf9934952f907184bb2312b9..52ad056381a105c730e886cb0b06f785e4311730 100644 (file)
@@ -45,7 +45,7 @@ static void print_bucket_class_ids(ostream& out, int t, CrushWrapper &crush)
     int c = i.first;
     int cid = i.second;
     const char* class_name = crush.get_class_name(c);
-    assert(class_name);
+    ceph_assert(class_name);
     out << "\tid " << cid << " class " << class_name << "\t\t# do not change unnecessarily\n";
   }
 }
@@ -161,7 +161,7 @@ int CrushCompiler::decompile_bucket(int cur,
     std::map<int, dcb_state_t>::value_type val(cur, DCB_STATE_IN_PROGRESS);
     std::pair <std::map<int, dcb_state_t>::iterator, bool> rval
       (dcb_states.insert(val));
-    assert(rval.second);
+    ceph_assert(rval.second);
     c = rval.first;
   }
   else if (c->second == DCB_STATE_DONE) {
@@ -647,7 +647,7 @@ int CrushCompiler::parse_bucket(iter_t const& i)
 
   // now do the items.
   if (!used_items.empty())
-    size = MAX(size, *used_items.rbegin());
+    size = std::max(size, *used_items.rbegin());
   vector<int> items(size);
   vector<int> weights(size);
 
@@ -741,10 +741,10 @@ int CrushCompiler::parse_bucket(iter_t const& i)
   item_id[name] = id;
   item_weight[id] = bucketweight;
   
-  assert(id != 0);
+  ceph_assert(id != 0);
   int idout;
   int r = crush.add_bucket(id, alg, hash, type, size,
-                           &items[0], &weights[0], &idout);
+                           items.data(), weights.data(), &idout);
   if (r < 0) {
     if (r == -EEXIST)
       err << "Duplicate bucket id " << id << std::endl;
@@ -925,7 +925,7 @@ int CrushCompiler::parse_rule(iter_t const& i)
       return -1;
     }
   }
-  assert(step == steps);
+  ceph_assert(step == steps);
   return 0;
 }
 
@@ -1025,8 +1025,13 @@ int CrushCompiler::parse_choose_args(iter_t const& i)
     err << choose_arg_index << " duplicated" << std::endl;
     return -1;
   }
+  const auto max_buckets = crush.get_max_buckets();
+  if (max_buckets < 0) {
+    err << "get_max_buckets() returned error" << std::endl;
+    return -1;
+  }
   crush_choose_arg_map arg_map;
-  arg_map.size = crush.get_max_buckets();
+  arg_map.size = max_buckets;
   arg_map.args = (crush_choose_arg *)calloc(arg_map.size, sizeof(crush_choose_arg));
   for (iter_t p = i->children.begin() + 2; p != i->children.end(); p++) {
     int r = 0;
@@ -1250,7 +1255,7 @@ int CrushCompiler::compile(istream& in, const char *infn)
     int cpos = info.stop - start;
     //out << "cpos " << cpos << std::endl;
     //out << " linemap " << line_pos << std::endl;
-    assert(!line_pos.empty());
+    ceph_assert(!line_pos.empty());
     map<int,int>::iterator p = line_pos.upper_bound(cpos);
     if (p != line_pos.begin())
       --p;