From ff280b6236d27fcb162cf65ecdf9a3f535ca5ad1 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Wed, 12 Jun 2013 20:59:49 -0700 Subject: [PATCH] Clean up CrushWrapper methods that take string: no c_str() necessary Signed-off-by: Dan Mick Reviewed-by: Sage Weil --- src/crush/CrushWrapper.cc | 8 ++++---- src/crush/CrushWrapper.h | 2 +- src/crushtool.cc | 8 ++++---- src/mon/OSDMonitor.cc | 18 +++++++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/crush/CrushWrapper.cc b/src/crush/CrushWrapper.cc index f0ae6dd9488fe..8a9addfb6c280 100644 --- a/src/crush/CrushWrapper.cc +++ b/src/crush/CrushWrapper.cc @@ -255,14 +255,14 @@ int CrushWrapper::get_full_location_ordered(int id, vector 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 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 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); } } diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index c123da3d9d528..f5a88c8bdd555 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -633,7 +633,7 @@ private: pair 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); diff --git a/src/crushtool.cc b/src/crushtool.cc index 054c4df86988f..75c26c098b667 100644 --- a/src/crushtool.cc +++ b/src/crushtool.cc @@ -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) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 214b0e7a92645..bdfea6f7a909c 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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; -- 2.39.5