]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rbd_mirror: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:44:59 +0000 (11:44 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:21:39 +0000 (12:21 +0800)
* 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 <kchai@redhat.com>
src/test/rbd_mirror/image_map/test_Policy.cc
src/test/rbd_mirror/image_replayer/journal/test_mock_Replayer.cc
src/test/rbd_mirror/image_replayer/snapshot/test_mock_Replayer.cc
src/test/rbd_mirror/random_write.cc
src/test/rbd_mirror/test_ClusterWatcher.cc
src/test/rbd_mirror/test_ImageReplayer.cc
src/test/rbd_mirror/test_PoolWatcher.cc
src/test/rbd_mirror/test_fixture.cc
src/test/rbd_mirror/test_mock_PoolWatcher.cc

index 5f8bdd17fbe1db39354551597b56610562ec1318..e60ffbfd53cf986dd89c83d40cac3b5f12dd12a3 100644 (file)
@@ -24,7 +24,7 @@ public:
                                   "0"));
 
     CephContext *cct = reinterpret_cast<CephContext *>(m_local_io_ctx.cct());
-    std::string policy_type = cct->_conf.get_val<string>("rbd_mirror_image_policy_type");
+    std::string policy_type = cct->_conf.get_val<std::string>("rbd_mirror_image_policy_type");
 
     if (policy_type == "none" || policy_type == "simple") {
       m_policy = image_map::SimplePolicy::create(m_local_io_ctx);
index 211216eeb941952e6659cce4f4d50917cb715eb5..7c8defb3d60e88bac9b9ad13ff3d3db080ce567d 100644 (file)
@@ -18,6 +18,8 @@
 #include "test/rbd_mirror/mock/MockSafeTimer.h"
 #include <boost/intrusive_ptr.hpp>
 
+using namespace std::chrono_literals;
+
 namespace librbd {
 
 namespace {
index 5567312f2acfae657ca5e6e0a2b5713a81d617d6..4798e36761727df05a2663f1a1f0c5b8f71d9041 100644 (file)
@@ -23,6 +23,8 @@
 #include "test/rbd_mirror/mock/MockContextWQ.h"
 #include "test/rbd_mirror/mock/MockSafeTimer.h"
 
+using namespace std::chrono_literals;
+
 namespace librbd {
 namespace {
 
index 6cb544c4508af9217e69dde88df39c039ecdb40e..373d004a71fce715f575cce1c440427002225367 100644 (file)
@@ -81,7 +81,7 @@ void rbd_bencher_completion(void *vc, void *pc) {
   //cout << "complete " << c << std::endl;
   int ret = c->get_return_value();
   if (ret != 0) {
-    cout << "write error: " << cpp_strerror(ret) << std::endl;
+    std::cout << "write error: " << cpp_strerror(ret) << std::endl;
     exit(ret < 0 ? -ret : ret);
   }
   b->lock.lock();
@@ -104,7 +104,7 @@ void write_image(librbd::Image &image) {
   image.size(&size);
   ceph_assert(size != 0);
 
-  vector<uint64_t> thread_offset;
+  std::vector<uint64_t> thread_offset;
   uint64_t i;
   uint64_t start_pos;
 
@@ -152,7 +152,7 @@ int main(int argc, const char **argv)
   std::vector<const char*> 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)) {
index 03fd3b14247e76bf27ff9570e1bca5741c1a4d26..005a83c1d8ec939288dd6a78825e20247dce3c18 100644 (file)
@@ -166,8 +166,8 @@ public:
 
   RadosRef m_cluster;
   ceph::mutex m_lock = ceph::make_mutex("TestClusterWatcherLock");
-  unique_ptr<rbd::mirror::ServiceDaemon<>> m_service_daemon;
-  unique_ptr<ClusterWatcher> m_cluster_watcher;
+  std::unique_ptr<rbd::mirror::ServiceDaemon<>> m_service_daemon;
+  std::unique_ptr<ClusterWatcher> m_cluster_watcher;
 
   set<string> m_pools;
   ClusterWatcher::PoolPeers m_pool_peers;
index cb21fc7239619fd02b842d71c0d409df718fdd0c..1f2b4396efe90498189af5e132cc747e22bc768f 100644 (file)
@@ -272,7 +272,7 @@ public:
     return "image" + stringify(++_image_number);
   }
 
-  std::string get_image_id(librados::IoCtx &ioctx, const string &image_name)
+  std::string get_image_id(librados::IoCtx &ioctx, const std::string &image_name)
   {
     std::string obj = librbd::util::id_obj_name(image_name);
     std::string id;
index c29ed65afb25c7cc703a404183215c1654ca41cc..351bba2175b0501ae898409bb66ce690fb98df9f 100644 (file)
@@ -30,6 +30,8 @@
 #include <set>
 #include <vector>
 
+using namespace std::chrono_literals;
+
 using rbd::mirror::ImageId;
 using rbd::mirror::ImageIds;
 using rbd::mirror::PoolWatcher;
@@ -218,7 +220,7 @@ public:
   ceph::mutex m_lock = ceph::make_mutex("TestPoolWatcherLock");
   RadosRef m_cluster;
   PoolWatcherListener m_pool_watcher_listener;
-  unique_ptr<PoolWatcher<> > m_pool_watcher;
+  std::unique_ptr<PoolWatcher<> > m_pool_watcher;
 
   set<string> m_pools;
   ImageIds m_mirrored_images;
index 7abf0e3e2a5c26b4e19cd3bf104863b435301dbb..f2fd3551ff276deae313fd9669bb24874e570cc6 100644 (file)
@@ -64,7 +64,7 @@ void TestFixture::SetUp() {
   if (!seeded) {
     seeded = true;
     int seed = getpid();
-    cout << "seed " << seed << std::endl;
+    std::cout << "seed " << seed << std::endl;
     srand(seed);
   }
 
index 44efc0532d8120ef990db089aaecadf680a1ddbf..958d934590e30dd6aa452bfac3dab6fb615ac798 100644 (file)
@@ -13,6 +13,8 @@
 #include "tools/rbd_mirror/pool_watcher/RefreshImagesRequest.h"
 #include "include/stringify.h"
 
+using namespace std::chrono_literals;
+
 namespace librbd {
 namespace {