]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Clean up CrushWrapper methods that take string: no c_str() necessary
authorDan Mick <dan.mick@inktank.com>
Thu, 13 Jun 2013 03:59:49 +0000 (20:59 -0700)
committerDan Mick <dan.mick@inktank.com>
Thu, 13 Jun 2013 04:56:17 +0000 (21:56 -0700)
Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/crush/CrushWrapper.cc
src/crush/CrushWrapper.h
src/crushtool.cc
src/mon/OSDMonitor.cc

index f0ae6dd9488fe7cddc032a940f42c35ae7e924df..8a9addfb6c2801c06df1a022784e5af0875ef080 100644 (file)
@@ -255,14 +255,14 @@ int CrushWrapper::get_full_location_ordered(int id, vector<pair<string, string>
   string high_type_name = type_map[high_type];
 
   path.push_back(parent_coord);
-  parent_id = get_item_id( (parent_coord.second).c_str() );
+  parent_id = get_item_id(parent_coord.second);
 
 
   while (parent_coord.first != high_type_name) {
     parent_coord = get_immediate_parent(parent_id);
     path.push_back(parent_coord);
     if ( parent_coord.first != high_type_name ){
-      parent_id = get_item_id( (parent_coord.second).c_str() );
+      parent_id = get_item_id(parent_coord.second);
     }
   }
 
@@ -291,7 +291,7 @@ map<int, string> CrushWrapper::get_parent_hierarchy(int id)
       high_type = (*it).first;
   }
 
-  parent_id = get_item_id((parent_coord.second).c_str());
+  parent_id = get_item_id(parent_coord.second);
 
   while (type_counter < high_type) {
     type_counter++;
@@ -300,7 +300,7 @@ map<int, string> CrushWrapper::get_parent_hierarchy(int id)
     if (type_counter < high_type){
       // get the coordinate information for the next parent
       parent_coord = get_immediate_parent(parent_id);
-      parent_id = get_item_id(parent_coord.second.c_str());
+      parent_id = get_item_id(parent_coord.second);
     }
   }
 
index c123da3d9d5282d610795198b0671c2b72cf1341..f5a88c8bdd55571cf31564d82ef15a805d411970 100644 (file)
@@ -633,7 +633,7 @@ private:
     pair<string, string> bucket_location = get_immediate_parent(item);
 
     // get the id of the parent bucket
-    int parent_id = get_item_id( (bucket_location.second).c_str() );
+    int parent_id = get_item_id(bucket_location.second);
 
     // get the parent bucket
     crush_bucket *parent_bucket = get_bucket(parent_id);
index 054c4df86988f5e35da85d7f1a50145981668034..75c26c098b66768a697a7dac8a50253383a1935c 100644 (file)
@@ -609,11 +609,11 @@ int main(int argc, const char **argv)
   if (!reweight_name.empty()) {
     cout << me << " reweighting item " << reweight_name << " to " << reweight_weight << std::endl;
     int r;
-    if (!crush.name_exists(reweight_name.c_str())) {
+    if (!crush.name_exists(reweight_name)) {
       cerr << " name " << reweight_name << " dne" << std::endl;
       r = -ENOENT;
     } else {
-      int item = crush.get_item_id(reweight_name.c_str());
+      int item = crush.get_item_id(reweight_name);
       r = crush.adjust_item_weightf(g_ceph_context, item, reweight_weight);
     }
     if (r >= 0)
@@ -627,11 +627,11 @@ int main(int argc, const char **argv)
   if (!remove_name.empty()) {
     cout << me << " removing item " << remove_name << std::endl;
     int r;
-    if (!crush.name_exists(remove_name.c_str())) {
+    if (!crush.name_exists(remove_name)) {
       cerr << " name " << remove_name << " dne" << std::endl;
       r = -ENOENT;
     } else {
-      int remove_item = crush.get_item_id(remove_name.c_str());
+      int remove_item = crush.get_item_id(remove_name);
       r = crush.remove_item(g_ceph_context, remove_item, false);
     }
     if (r == 0)
index 214b0e7a9264597d4fdee4e09ab21c83a4358c89..bdfea6f7a909ccb2cf708233546ae02408949b0c 100644 (file)
@@ -1697,7 +1697,7 @@ void OSDMonitor::tick()
 
        // is this an entire large subtree down?
        if (g_conf->mon_osd_down_out_subtree_limit.length()) {
-         int type = osdmap.crush->get_type_id(g_conf->mon_osd_down_out_subtree_limit.c_str());
+         int type = osdmap.crush->get_type_id(g_conf->mon_osd_down_out_subtree_limit);
          if (type > 0) {
            if (osdmap.containing_subtree_is_down(g_ceph_context, o, type, &down_cache)) {
              dout(10) << "tick entire containing " << g_conf->mon_osd_down_out_subtree_limit
@@ -2659,12 +2659,12 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       CrushWrapper newcrush;
       _get_pending_crush(newcrush);
 
-      if (!newcrush.name_exists(name.c_str())) {
+      if (!newcrush.name_exists(name)) {
        err = -ENOENT;
        ss << "item " << name << " does not exist";
        break;
       }
-      int id = newcrush.get_item_id(name.c_str());
+      int id = newcrush.get_item_id(name);
 
       if (!newcrush.check_item_loc(g_ceph_context, id, loc, (int *)NULL)) {
        err = newcrush.move_bucket(g_ceph_context, id, loc);
@@ -2696,12 +2696,12 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       CrushWrapper newcrush;
       _get_pending_crush(newcrush);
 
-      if (!newcrush.name_exists(name.c_str())) {
+      if (!newcrush.name_exists(name)) {
        err = -ENOENT;
        ss << "item " << name << " does not exist";
        break;
       }
-      int id = newcrush.get_item_id(name.c_str());
+      int id = newcrush.get_item_id(name);
 
       if (!newcrush.check_item_loc(g_ceph_context, id, loc, (int *)NULL)) {
        err = newcrush.link_bucket(g_ceph_context, id, loc);
@@ -2729,12 +2729,12 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
       string name;
       cmd_getval(g_ceph_context, cmdmap, "name", name);
 
-      if (!newcrush.name_exists(name.c_str())) {
+      if (!newcrush.name_exists(name)) {
        err = 0;
        ss << "device '" << name << "' does not appear in the crush map";
        break;
       }
-      int id = newcrush.get_item_id(name.c_str());
+      int id = newcrush.get_item_id(name);
       bool unlink_only = prefix == "osd crush unlink";
       string ancestor_str;
       if (cmd_getval(g_ceph_context, cmdmap, "ancestor", ancestor_str)) {
@@ -2773,13 +2773,13 @@ bool OSDMonitor::prepare_command(MMonCommand *m)
 
       string name;
       cmd_getval(g_ceph_context, cmdmap, "name", name);
-      if (!newcrush.name_exists(name.c_str())) {
+      if (!newcrush.name_exists(name)) {
        err = -ENOENT;
        ss << "device '" << name << "' does not appear in the crush map";
        break;
       }
 
-      int id = newcrush.get_item_id(name.c_str());
+      int id = newcrush.get_item_id(name);
       if (id < 0) {
        ss << "device '" << name << "' is not a leaf in the crush map";
        break;