From 7bc3e11ff9b4e2fc30e4447c057b411ddd49d2ab Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Aug 2021 11:41:42 +0800 Subject: [PATCH] tools/rbd_mirror: build without "using namespace std" * add "std::" prefix in headers * add "using" declarations in .cc files. so we don't rely on "using namespace std" in one or more included headers. Signed-off-by: Kefu Chai --- src/tools/rbd_mirror/ClusterWatcher.cc | 1 + src/tools/rbd_mirror/ImageMap.cc | 2 ++ src/tools/rbd_mirror/Mirror.cc | 1 + src/tools/rbd_mirror/Throttler.cc | 2 +- src/tools/rbd_mirror/main.cc | 2 +- 5 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/rbd_mirror/ClusterWatcher.cc b/src/tools/rbd_mirror/ClusterWatcher.cc index 2ae1306be5a3d..8bafb336e8e65 100644 --- a/src/tools/rbd_mirror/ClusterWatcher.cc +++ b/src/tools/rbd_mirror/ClusterWatcher.cc @@ -20,6 +20,7 @@ using std::list; using std::map; +using std::pair; using std::set; using std::string; using std::unique_ptr; diff --git a/src/tools/rbd_mirror/ImageMap.cc b/src/tools/rbd_mirror/ImageMap.cc index 4493e073b98bc..b73e090afadae 100644 --- a/src/tools/rbd_mirror/ImageMap.cc +++ b/src/tools/rbd_mirror/ImageMap.cc @@ -20,6 +20,8 @@ #define dout_prefix *_dout << "rbd::mirror::ImageMap: " << this << " " \ << __func__ << ": " +using namespace std; + namespace rbd { namespace mirror { diff --git a/src/tools/rbd_mirror/Mirror.cc b/src/tools/rbd_mirror/Mirror.cc index f02cfe65df568..38f35edcd4403 100644 --- a/src/tools/rbd_mirror/Mirror.cc +++ b/src/tools/rbd_mirror/Mirror.cc @@ -553,6 +553,7 @@ void Mirror::run() { dout(20) << "enter" << dendl; + using namespace std::chrono_literals; utime_t next_refresh_pools = ceph_clock_now(); while (!m_stopping) { diff --git a/src/tools/rbd_mirror/Throttler.cc b/src/tools/rbd_mirror/Throttler.cc index b2029896390c2..07d6e397ec66d 100644 --- a/src/tools/rbd_mirror/Throttler.cc +++ b/src/tools/rbd_mirror/Throttler.cc @@ -228,7 +228,7 @@ const char** Throttler::get_tracked_conf_keys() const { template void Throttler::handle_conf_change(const ConfigProxy& conf, - const set &changed) { + const std::set &changed) { if (changed.count(m_config_key)) { set_max_concurrent_ops(conf.get_val(m_config_key)); } diff --git a/src/tools/rbd_mirror/main.cc b/src/tools/rbd_mirror/main.cc index ab350a014cf80..78f3a5c2eb6ca 100644 --- a/src/tools/rbd_mirror/main.cc +++ b/src/tools/rbd_mirror/main.cc @@ -37,7 +37,7 @@ int main(int argc, const char **argv) std::vector args; argv_to_vec(argc, argv, args); if (args.empty()) { - cerr << argv[0] << ": -h or --help for usage" << std::endl; + std::cerr << argv[0] << ": -h or --help for usage" << std::endl; exit(1); } if (ceph_argparse_need_usage(args)) { -- 2.39.5