From b3d7cf423d433f7140145f8f95604f0984bd65e6 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 11 Aug 2021 11:57:31 +0800 Subject: [PATCH] libcephsqlite: 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/SimpleRADOSStriper.cc | 6 +++--- src/SimpleRADOSStriper.h | 4 ++-- src/blk/zoned/HMSMRDevice.cc | 2 ++ src/blk/zoned/HMSMRDevice.h | 4 ++-- src/libcephsqlite.cc | 2 +- src/test/libcephsqlite/main.cc | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/SimpleRADOSStriper.cc b/src/SimpleRADOSStriper.cc index d6fe101f9e9e3..3a64193d3e41c 100644 --- a/src/SimpleRADOSStriper.cc +++ b/src/SimpleRADOSStriper.cc @@ -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; diff --git a/src/SimpleRADOSStriper.h b/src/SimpleRADOSStriper.h index c5d3f5090ee39..ab60b4dd25958 100644 --- a/src/SimpleRADOSStriper.h +++ b/src/SimpleRADOSStriper.h @@ -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 blocklisted = false; bool shutdown = false; version_t version = 0; diff --git a/src/blk/zoned/HMSMRDevice.cc b/src/blk/zoned/HMSMRDevice.cc index 045d690eaf6f1..dd5101e4deb2e 100644 --- a/src/blk/zoned/HMSMRDevice.cc +++ b/src/blk/zoned/HMSMRDevice.cc @@ -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), diff --git a/src/blk/zoned/HMSMRDevice.h b/src/blk/zoned/HMSMRDevice.h index fd3ebf787106d..ea0bf31dbde05 100644 --- a/src/blk/zoned/HMSMRDevice.h +++ b/src/blk/zoned/HMSMRDevice.h @@ -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 *pm) const final; + std::map *pm) const final; int get_devname(std::string *s) const final { if (devname.empty()) { return -ENOENT; diff --git a/src/libcephsqlite.cc b/src/libcephsqlite.cc index 9765a933f3502..9e7a0629147fe 100644 --- a/src/libcephsqlite.cc +++ b/src/libcephsqlite.cc @@ -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; } diff --git a/src/test/libcephsqlite/main.cc b/src/test/libcephsqlite/main.cc index 78ab04888257f..28ab88e7cb965 100644 --- a/src/test/libcephsqlite/main.cc +++ b/src/test/libcephsqlite/main.cc @@ -1093,7 +1093,7 @@ out: int main(int argc, char **argv) { - vector args; + std::vector args; argv_to_vec(argc, (const char **)argv, args); std::string conf_file_list; -- 2.39.5