]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
libcephsqlite: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:57:31 +0000 (11:57 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:23:37 +0000 (12:23 +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/SimpleRADOSStriper.cc
src/SimpleRADOSStriper.h
src/blk/zoned/HMSMRDevice.cc
src/blk/zoned/HMSMRDevice.h
src/libcephsqlite.cc
src/test/libcephsqlite/main.cc

index d6fe101f9e9e36f86790256d367225476498e6da..3a64193d3e41c6684da4a79e5111e4eb5d61231b 100644 (file)
@@ -618,7 +618,7 @@ int SimpleRADOSStriper::recover_lock()
     entity_addrvec_t addrv;
     addrv.parse(addrs.c_str());
     auto R = librados::Rados(ioctx);
-    auto b = "blocklist"sv;
+    std::string_view b = "blocklist";
 retry:
     for (auto& a : addrv.v) {
       CachedStackStringStream css;
@@ -630,8 +630,8 @@ retry:
       d(5) << "sending blocklist command: " << cmd << dendl;
       std::string out;
       if (int rc = R.mon_command(css->str(), bufferlist(), nullptr, &out); rc < 0) {
-        if (rc == -EINVAL && b == "blocklist"sv) {
-          b = "blacklist"sv;
+        if (rc == -EINVAL && b == "blocklist") {
+          b = "blacklist";
           goto retry;
         }
         d(-1) << "Cannot proceed with recovery because I have failed to blocklist the old client: " << cpp_strerror(rc) << ", out = " << out << dendl;
index c5d3f5090ee39c4375fdf4b28991f17a7563c929..ab60b4dd25958805abd5ffe79f7e906df0badb47 100644 (file)
@@ -119,8 +119,8 @@ private:
   std::condition_variable lock_keeper_cvar;
   std::mutex lock_keeper_mutex;
   time last_renewal = time::min();
-  std::chrono::milliseconds lock_keeper_interval = 2000ms;
-  std::chrono::milliseconds lock_keeper_timeout = 30000ms;
+  std::chrono::milliseconds lock_keeper_interval{2000};
+  std::chrono::milliseconds lock_keeper_timeout{30000};
   std::atomic<bool> blocklisted = false;
   bool shutdown = false;
   version_t version = 0;
index 045d690eaf6f173936ee7d6fcee22095d062fbcc..dd5101e4deb2eb6b0b04e38f1e9585b05bb84ccf 100644 (file)
@@ -45,6 +45,8 @@ extern "C" {
 #undef dout_prefix
 #define dout_prefix *_dout << "smrbdev(" << this << " " << path << ") "
 
+using namespace std;
+
 HMSMRDevice::HMSMRDevice(CephContext* cct, aio_callback_t cb, void *cbpriv, aio_callback_t d_cb, void *d_cbpriv)
   : BlockDevice(cct, cb, cbpriv),
     aio(false), dio(false),
index fd3ebf787106d1ef20b9b3adf0eaa215ad43f7df..ea0bf31dbde05c9f896e02e8aaafd01f546d172b 100644 (file)
@@ -38,7 +38,7 @@ class HMSMRDevice final : public BlockDevice {
   bool aio, dio;
 
   int vdo_fd = -1;      ///< fd for vdo sysfs directory
-  string vdo_name;
+  std::string vdo_name;
 
   std::string devname;  ///< kernel dev name (/sys/block/$devname), if any
   int zbd_fd = -1;     ///< fd for the zoned block device
@@ -124,7 +124,7 @@ public:
   void discard_drain() final;
 
   int collect_metadata(const std::string& prefix,
-                       map<std::string,std::string> *pm) const final;
+                       std::map<std::string,std::string> *pm) const final;
   int get_devname(std::string *s) const final {
     if (devname.empty()) {
       return -ENOENT;
index 9765a933f3502e790b21f5067e02ee7d16930f84..9e7a0629147feb253d11d91dd8c1c259308252e6 100644 (file)
@@ -510,7 +510,7 @@ static int Open(sqlite3_vfs *vfs, const char *name, sqlite3_file *file,
     return SQLITE_CANTOPEN;
   }
   auto path = std::string_view(name);
-  if (path == ":memory:"sv) {
+  if (path == ":memory:") {
     dv(-1) << " cannot open temporary database" << dendl;
     return SQLITE_IOERR;
   }
index 78ab04888257f6d7e22bb4ab9fe53df26de7279b..28ab88e7cb965223b02a301563043ee426431a6b 100644 (file)
@@ -1093,7 +1093,7 @@ out:
 
 
 int main(int argc, char **argv) {
-  vector<const char*> args;
+  std::vector<const char*> args;
   argv_to_vec(argc, (const char **)argv, args);
 
   std::string conf_file_list;