From: Kefu Chai Date: Wed, 11 Aug 2021 03:53:50 +0000 (+0800) Subject: os: build without "using namespace std" X-Git-Tag: v17.1.0~1121^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8801f97219b911eb1c6f13842b2079d76cac7b60;p=ceph.git os: 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 --- diff --git a/src/os/FuseStore.cc b/src/os/FuseStore.cc index dd9833e0861f..a1a9aa6d007c 100644 --- a/src/os/FuseStore.cc +++ b/src/os/FuseStore.cc @@ -27,6 +27,7 @@ #undef dout_prefix #define dout_prefix *_dout << "fuse " +using std::less; using std::list; using std::map; using std::set; diff --git a/src/os/Transaction.cc b/src/os/Transaction.cc index ac3513ef4a4f..f99b25220508 100644 --- a/src/os/Transaction.cc +++ b/src/os/Transaction.cc @@ -4,6 +4,7 @@ #include "os/Transaction.h" #include "common/Formatter.h" +using std::less; using std::list; using std::map; using std::ostream; diff --git a/src/os/Transaction.h b/src/os/Transaction.h index f016aa6c315e..f28a257fcefc 100644 --- a/src/os/Transaction.h +++ b/src/os/Transaction.h @@ -744,7 +744,7 @@ public: return t->get_fadvise_flags(); } - const vector &get_objects() const { + const std::vector &get_objects() const { return objects; } }; diff --git a/src/os/bluestore/Allocator.h b/src/os/bluestore/Allocator.h index 59be4a711d28..6f6325d57af9 100644 --- a/src/os/bluestore/Allocator.h +++ b/src/os/bluestore/Allocator.h @@ -70,7 +70,7 @@ public: int64_t block_size, const std::string_view name = ""); - const string& get_name() const; + const std::string& get_name() const; int64_t get_capacity() const { return device_size; diff --git a/src/os/bluestore/BitmapFreelistManager.h b/src/os/bluestore/BitmapFreelistManager.h index c6bfe469f1b4..5b04e8fd28cc 100644 --- a/src/os/bluestore/BitmapFreelistManager.h +++ b/src/os/bluestore/BitmapFreelistManager.h @@ -93,7 +93,7 @@ public: return bytes_per_block; } void get_meta(uint64_t target_size, - std::vector>*) const override; + std::vector>*) const override; }; #endif diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 6f92965e4eff..fe0b9aca9410 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -214,7 +214,7 @@ public: buffer_appender.append(buf, len); } - void append(const byte *buf, size_t len) { + void append(const std::byte *buf, size_t len) { // allow callers to use byte type instead of char* as we simply pass byte array append((const char*)buf, len); } diff --git a/src/os/bluestore/BlueRocksEnv.cc b/src/os/bluestore/BlueRocksEnv.cc index 045f773ac3ff..0d76a8597190 100644 --- a/src/os/bluestore/BlueRocksEnv.cc +++ b/src/os/bluestore/BlueRocksEnv.cc @@ -7,6 +7,8 @@ #include "kv/RocksDBStore.h" #include "string.h" +using std::string_view; + namespace { rocksdb::Status err_to_status(int r) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index fe1a11b9b596..4f0b410e478a 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -84,12 +84,15 @@ MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::SharedBlob, bluestore_shared_blob, // bluestore_txc MEMPOOL_DEFINE_OBJECT_FACTORY(BlueStore::TransContext, bluestore_transcontext, bluestore_txc); +using std::byte; using std::deque; using std::min; using std::make_pair; using std::numeric_limits; using std::pair; +using std::less; using std::list; +using std::make_unique; using std::map; using std::max; using std::ostream; @@ -97,6 +100,7 @@ using std::ostringstream; using std::set; using std::string; using std::stringstream; +using std::unique_ptr; using std::vector; using ceph::bufferlist; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index f553db3454e6..5db9ec08a1ba 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2420,7 +2420,7 @@ public: private: int _check_or_set_bdev_label(std::string path, uint64_t size, std::string desc, bool create); - int _set_bdev_label_size(const string& path, uint64_t size); + int _set_bdev_label_size(const std::string& path, uint64_t size); int _open_super_meta(); @@ -2700,7 +2700,7 @@ public: int expand_devices(std::ostream& out); std::string get_device_path(unsigned id); - int dump_bluefs_sizes(ostream& out); + int dump_bluefs_sizes(std::ostream& out); public: int statfs(struct store_statfs_t *buf, @@ -3086,7 +3086,7 @@ private: std::lock_guard l(qlock); disk_size_mismatch_alert = s; } - void _set_spurious_read_errors_alert(const string& s) { + void _set_spurious_read_errors_alert(const std::string& s) { std::lock_guard l(qlock); spurious_read_errors_alert = s; } diff --git a/src/os/bluestore/FreelistManager.h b/src/os/bluestore/FreelistManager.h index 18ca45f85649..4d375b430945 100644 --- a/src/os/bluestore/FreelistManager.h +++ b/src/os/bluestore/FreelistManager.h @@ -50,7 +50,7 @@ public: virtual uint64_t get_alloc_size() const = 0; virtual void get_meta(uint64_t target_size, - std::vector>*) const = 0; + std::vector>*) const = 0; void set_null_manager() { null_manager = true; diff --git a/src/os/bluestore/ZonedFreelistManager.h b/src/os/bluestore/ZonedFreelistManager.h index 14ea9e39e76b..c6f9be3151e9 100644 --- a/src/os/bluestore/ZonedFreelistManager.h +++ b/src/os/bluestore/ZonedFreelistManager.h @@ -22,7 +22,7 @@ using cfg_reader_t = std::function; -const string CLEANING_IN_PROGRESS_KEY = "cleaning_in_progress"; +const std::string CLEANING_IN_PROGRESS_KEY = "cleaning_in_progress"; class ZonedFreelistManager : public FreelistManager { std::string meta_prefix; ///< device size, zone size, etc. @@ -99,7 +99,7 @@ public: } void get_meta(uint64_t target_size, - std::vector>*) const override; + std::vector>*) const override; std::vector get_zone_states(KeyValueDB *kvdb) const; std::set get_cleaning_in_progress_zones(KeyValueDB *kvdb) const; diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index ee03dc1a02cd..b215d3e9ed17 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -23,6 +23,7 @@ #include "common/admin_socket.h" #include "kv/RocksDBStore.h" +using namespace std; namespace fs = std::filesystem; namespace po = boost::program_options; diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index 323bb6521cef..5ee012b04e29 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -109,6 +109,7 @@ #define __FUNC__ __func__ << "(" << __LINE__ << ")" using std::cerr; +using std::less; using std::list; using std::make_pair; using std::map; diff --git a/src/os/kstore/KStore.cc b/src/os/kstore/KStore.cc index fe030859e22a..9526a756419c 100644 --- a/src/os/kstore/KStore.cc +++ b/src/os/kstore/KStore.cc @@ -45,6 +45,7 @@ */ +using std::less; using std::list; using std::make_pair; using std::map;