From 3126533d2660a4399d0627a5e33007f300b69df1 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Thu, 28 Sep 2023 23:44:09 +0530 Subject: [PATCH 1/2] mon/AuthMonitor: remove unused namespace imports Don't import items into current namespace when they'll be never used. Signed-off-by: Rishabh Dave --- src/mon/AuthMonitor.cc | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index d1ae6571335..6c0763c2ae4 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -42,10 +42,6 @@ #define dout_prefix _prefix(_dout, mon, get_last_committed()) using namespace TOPNSPC::common; -using std::cerr; -using std::cout; -using std::dec; -using std::hex; using std::list; using std::map; using std::make_pair; @@ -53,23 +49,16 @@ using std::ostream; using std::ostringstream; using std::pair; using std::set; -using std::setfill; using std::string; using std::stringstream; -using std::to_string; using std::vector; -using std::unique_ptr; using ceph::bufferlist; using ceph::decode; using ceph::encode; using ceph::Formatter; -using ceph::JSONFormatter; -using ceph::make_message; -using ceph::mono_clock; -using ceph::mono_time; -using ceph::timespan_str; -static ostream& _prefix(std::ostream *_dout, Monitor &mon, version_t v) { + +static ostream& _prefix(ostream *_dout, Monitor &mon, version_t v) { return *_dout << "mon." << mon.name << "@" << mon.rank << "(" << mon.get_state_name() << ").auth v" << v << " "; From 8545784a982f76bb5694704b700910813fc5ee56 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 4 Oct 2023 23:52:27 +0530 Subject: [PATCH 2/2] mon/AuthMonitor: make use of imported namespace symbols Once a symbol has been imported into the current namespace, no need to mention the original namespace while using it. IOW, no need to write "std::string" after it has been imported from the namespace "std" into the current namespace. Signed-off-by: Rishabh Dave --- src/mon/AuthMonitor.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 6c0763c2ae4..0abbc790f83 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -82,7 +82,7 @@ bool AuthMonitor::check_rotate() } void AuthMonitor::process_used_pending_keys( - const std::map& used_pending_keys) + const map& used_pending_keys) { for (auto& [name, used_key] : used_pending_keys) { dout(10) << __func__ << " used pending_key for " << name << dendl; @@ -1703,7 +1703,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) err = -EINVAL; goto done; } else { - mon_cap_string += " fsname=" + std::string(fs->get_mds_map().get_fs_name()); + mon_cap_string += " fsname=" + string(fs->get_mds_map().get_fs_name()); } } @@ -1745,7 +1745,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) mds_cap_string += "allow " + cap; if (filesystem != "*" && filesystem != "all" && fs != nullptr) { - mds_cap_string += " fsname=" + std::string(fs->get_mds_map().get_fs_name()); + mds_cap_string += " fsname=" + string(fs->get_mds_map().get_fs_name()); } if (path != "/") { @@ -2068,7 +2068,7 @@ bool AuthMonitor::_upgrade_format_to_dumpling() // set daemon profiles if ((p->first.is_osd() || p->first.is_mds()) && mon_caps == "allow rwx") { - new_caps = string("allow profile ") + std::string(p->first.get_type_name()); + new_caps = string("allow profile ") + string(p->first.get_type_name()); } // update bootstrap keys