]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:54:56 +0000 (11:54 +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>
14 files changed:
src/cls/2pc_queue/cls_2pc_queue_client.cc
src/cls/2pc_queue/cls_2pc_queue_client.h
src/cls/cas/cls_cas_internal.cc
src/cls/cas/cls_cas_internal.h
src/cls/fifo/cls_fifo_ops.h
src/cls/fifo/cls_fifo_types.h
src/cls/lock/cls_lock_ops.cc
src/cls/lua/cls_lua.cc
src/cls/queue/cls_queue_client.cc
src/cls/queue/cls_queue_client.h
src/cls/queue/cls_queue_src.cc
src/cls/rgw/cls_rgw_client.h
src/cls/rgw/cls_rgw_ops.h
src/cls/timeindex/cls_timeindex_types.cc

index 3eb2d0f6a0bd8ecbc40fbcf42822d735508b35a0..6868b2b6f83ee88a2eeb6fc5eca4ba25562437f4 100644 (file)
@@ -32,7 +32,7 @@ int cls_2pc_queue_get_capacity_result(const bufferlist& bl, uint64_t& size) {
 }
 
 #ifndef CLS_CLIENT_HIDE_IOCTX
-int cls_2pc_queue_get_capacity(IoCtx& io_ctx, const string& queue_name, uint64_t& size) {
+int cls_2pc_queue_get_capacity(IoCtx& io_ctx, const std::string& queue_name, uint64_t& size) {
   bufferlist in, out;
   const auto r = io_ctx.exec(queue_name, TPC_QUEUE_CLASS, TPC_QUEUE_GET_CAPACITY, in, out);
   if (r < 0 ) {
@@ -64,7 +64,7 @@ int cls_2pc_queue_reserve_result(const bufferlist& bl, cls_2pc_reservation::id_t
   return 0;
 }
 
-int cls_2pc_queue_reserve(IoCtx& io_ctx, const string& queue_name, 
+int cls_2pc_queue_reserve(IoCtx& io_ctx, const std::string& queue_name,
         uint64_t res_size, uint32_t entries, cls_2pc_reservation::id_t& res_id) {
   bufferlist in, out;
   cls_2pc_queue_reserve_op reserve_op;
@@ -131,9 +131,11 @@ int cls_2pc_queue_list_entries_result(const bufferlist& bl, std::vector<cls_queu
 }
 
 #ifndef CLS_CLIENT_HIDE_IOCTX
-int cls_2pc_queue_list_entries(IoCtx& io_ctx, const string& queue_name, const string& marker, uint32_t max,
-                            std::vector<cls_queue_entry>& entries,
-                            bool *truncated, std::string& next_marker) {
+int cls_2pc_queue_list_entries(IoCtx& io_ctx,
+                               const std::string& queue_name,
+                               const std::string& marker, uint32_t max,
+                               std::vector<cls_queue_entry>& entries,
+                               bool *truncated, std::string& next_marker) {
   bufferlist in, out;
   cls_queue_list_op op;
   op.start_marker = marker;
index bbdfcc2e089318de34be806487de421f8035f8a6..e0bdeafd59098c253c6a46edddebe6708ef1fe21 100644 (file)
@@ -18,7 +18,7 @@ void cls_2pc_queue_init(librados::ObjectWriteOperation& op, const std::string& q
 // rgw_rados_operate() should be called after the overloads w/o calls to io_ctx.operate()/exec()
 #ifndef CLS_CLIENT_HIDE_IOCTX
 // return capacity (bytes)
-int cls_2pc_queue_get_capacity(librados::IoCtx& io_ctx, const string& queue_name, uint64_t& size);
+int cls_2pc_queue_get_capacity(librados::IoCtx& io_ctx, const std::string& queue_name, uint64_t& size);
 
 // make a reservation on the queue (in bytes) and number of expected entries (to calculate overhead)
 // return a reservation id if reservations is possible, 0 otherwise
index edaa96d2737053bcea3c58ddf0e0b43bb4d2d06b..891b1c311bf1b412b517570bc10ba932f997e314 100644 (file)
@@ -129,7 +129,8 @@ void chunk_refs_t::decode(ceph::buffer::list::const_iterator& p)
     break;
   default:
     throw ceph::buffer::malformed_input(
-      "unrecognized chunk ref encoding type "s + stringify((int)t));
+      std::string("unrecognized chunk ref encoding type ") +
+      stringify((int)t));
   }
   DECODE_FINISH(p);
 }
index 14d3119a9d247b34c8da71d7d9e8be275314b1da..09e7f9f1f69d345dc89d8cdb0b652574364676b9 100644 (file)
@@ -157,12 +157,13 @@ struct chunk_refs_by_hash_t : public chunk_refs_t::refs_t {
   chunk_refs_by_hash_t(const chunk_refs_by_object_t *o) {
     total = o->count();
     for (auto& i : o->by_object) {
-      by_hash[make_pair(i.pool, i.get_hash())]++;
+      by_hash[std::make_pair(i.pool, i.get_hash())]++;
     }
   }
 
   std::string describe_encoding() const {
-    return "by_hash("s + stringify(hash_bits) + " bits)"s;
+    using namespace std::literals;
+    return "by_hash("s + stringify(hash_bits) + " bits)";
   }
 
   uint32_t mask() {
@@ -181,7 +182,7 @@ struct chunk_refs_by_hash_t : public chunk_refs_t::refs_t {
     old.swap(by_hash);
     auto m = mask();
     for (auto& i : old) {
-      by_hash[make_pair(i.first.first, i.first.second & m)] = i.second;
+      by_hash[std::make_pair(i.first.first, i.first.second & m)] = i.second;
     }
     return true;
   }
@@ -196,11 +197,11 @@ struct chunk_refs_by_hash_t : public chunk_refs_t::refs_t {
     return total;
   }
   void get(const hobject_t& o) override {
-    by_hash[make_pair(o.pool, o.get_hash() & mask())]++;
+    by_hash[std::make_pair(o.pool, o.get_hash() & mask())]++;
     ++total;
   }
   bool put(const hobject_t& o) override {
-    auto p = by_hash.find(make_pair(o.pool, o.get_hash() & mask()));
+    auto p = by_hash.find(std::make_pair(o.pool, o.get_hash() & mask()));
     if (p == by_hash.end()) {
       return false;
     }
@@ -242,7 +243,7 @@ struct chunk_refs_by_hash_t : public chunk_refs_t::refs_t {
       denc_signed_varint(poolid, p);
       memcpy(&hash, p.get_pos_add(hash_bytes), hash_bytes);
       denc_varint(count, p);
-      by_hash[make_pair(poolid, (uint32_t)hash)] = count;
+      by_hash[std::make_pair(poolid, (uint32_t)hash)] = count;
     }
     DENC_FINISH(p);
   }
@@ -265,7 +266,7 @@ WRITE_CLASS_DENC(chunk_refs_by_hash_t)
 
 struct chunk_refs_by_pool_t : public chunk_refs_t::refs_t {
   uint64_t total = 0;
-  map<int64_t,uint64_t> by_pool;
+  std::map<int64_t,uint64_t> by_pool;
 
   chunk_refs_by_pool_t() {}
   chunk_refs_by_pool_t(const chunk_refs_by_hash_t *o) {
index a3f4ae237c9c5f6b52274dffc46b16f4416924ae..91a012c0847ec4c842d3cc6b7e1b1aaa4cd2213d 100644 (file)
@@ -215,7 +215,7 @@ WRITE_CLASS_ENCODER(trim_part)
 
 struct list_part
 {
-  std::optional<string> tag;
+  std::optional<std::string> tag;
   std::uint64_t ofs{0};
   int max_entries{100};
 
index 749f66e7b96e67184377e75495c4777fcf7563c0..8a471828b7a5ac139b8876cebdc53d2aaa5822f0 100644 (file)
@@ -76,7 +76,7 @@ struct objv {
   }
 };
 WRITE_CLASS_ENCODER(objv)
-inline ostream& operator <<(std::ostream& os, const objv& objv)
+inline std::ostream& operator <<(std::ostream& os, const objv& objv)
 {
   return os << objv.to_str();
 }
@@ -310,7 +310,7 @@ struct info {
   std::int64_t max_push_part_num{-1};
 
   std::string head_tag;
-  std::map<int64_t, string> tags;
+  std::map<int64_t, std::string> tags;
 
   std::multimap<int64_t, journal_entry> journal;
 
index ef4190c0a3c79b46bdf3b4b88c212c3d24dbf274..1f878be48eb75ad9eb221e1b39a43c27e515d924 100644 (file)
@@ -18,6 +18,9 @@
 #include "cls/lock/cls_lock_ops.h"
 
 using namespace rados::cls::lock;
+using std::list;
+using std::map;
+using std::string;
 
 static void generate_lock_id(locker_id_t& i, int n, const string& cookie)
 {
index ecc5417fca46b171a076c1c845ecc78f5f08d26b..dea5fe1a8248c33077d9084eeaae7e49f2f32111 100644 (file)
@@ -12,6 +12,8 @@
 #include "cls_lua.h"
 #include "cls_lua_ops.h"
 
+using namespace std;
+
 CLS_VER(1,0)
 CLS_NAME(lua)
 
index 97f67d3d74ee8d881cb6ab162f83b627fd10186c..87d17bb9e3157df6ba9ae2cf8194415fb1838ee6 100644 (file)
@@ -6,6 +6,7 @@
 #include "cls/queue/cls_queue_const.h"
 #include "cls/queue/cls_queue_client.h"
 
+using namespace std;
 using namespace librados;
 
 void cls_queue_init(ObjectWriteOperation& op, const string& queue_name, uint64_t size)
index 59d32bfa1a7584e02c60feafe2a2b1cce348c137..895a51c117379c6fbb3af5916aee30cff336aa51 100644 (file)
@@ -6,11 +6,11 @@
 #include "cls_queue_ops.h"
 #include "common/ceph_time.h"
 
-void cls_queue_init(librados::ObjectWriteOperation& op, const string& queue_name, uint64_t size);
-int cls_queue_get_capacity(librados::IoCtx& io_ctx, const string& oid, uint64_t& size);
-void cls_queue_enqueue(librados::ObjectWriteOperation& op, uint32_t expiration_secs, vector<bufferlist> bl_data_vec);
-int cls_queue_list_entries(librados::IoCtx& io_ctx, const string& oid, const string& marker, uint32_t max,
-                    vector<cls_queue_entry>& entries, bool *truncated, string& next_marker);
-void cls_queue_remove_entries(librados::ObjectWriteOperation& op, const string& end_marker);
+void cls_queue_init(librados::ObjectWriteOperation& op, const std::string& queue_name, uint64_t size);
+int cls_queue_get_capacity(librados::IoCtx& io_ctx, const std::string& oid, uint64_t& size);
+void cls_queue_enqueue(librados::ObjectWriteOperation& op, uint32_t expiration_secs, std::vector<bufferlist> bl_data_vec);
+int cls_queue_list_entries(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, uint32_t max,
+                    std::vector<cls_queue_entry>& entries, bool *truncated, std::string& next_marker);
+void cls_queue_remove_entries(librados::ObjectWriteOperation& op, const std::string& end_marker);
 
-#endif
\ No newline at end of file
+#endif
index 8806b5804971ae7476b31953410a5c6d9f7b30dc..bd973352d425d88609d4e24c6a2ebb67af3f433e 100644 (file)
@@ -9,6 +9,7 @@
 #include "cls/queue/cls_queue_const.h"
 #include "cls/queue/cls_queue_src.h"
 
+using std::string;
 using ceph::bufferlist;
 using ceph::decode;
 using ceph::encode;
index 67508b21f277e3e0ad9d331ca587794f91921a26..74cc25f0eaab557807afdd2a4b970f61de7abeb7 100644 (file)
@@ -599,13 +599,13 @@ int cls_rgw_gc_list(librados::IoCtx& io_ctx, std::string& oid, std::string& mark
 #ifndef CLS_CLIENT_HIDE_IOCTX
 int cls_rgw_lc_get_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
 int cls_rgw_lc_put_head(librados::IoCtx& io_ctx, const std::string& oid, cls_rgw_lc_obj_head& head);
-int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, string& marker, cls_rgw_lc_entry& entry);
+int cls_rgw_lc_get_next_entry(librados::IoCtx& io_ctx, const std::string& oid, std::string& marker, cls_rgw_lc_entry& entry);
 int cls_rgw_lc_rm_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
 int cls_rgw_lc_set_entry(librados::IoCtx& io_ctx, const std::string& oid, const cls_rgw_lc_entry& entry);
 int cls_rgw_lc_get_entry(librados::IoCtx& io_ctx, const std::string& oid, const std::string& marker, cls_rgw_lc_entry& entry);
 int cls_rgw_lc_list(librados::IoCtx& io_ctx, const std::string& oid,
                    const std::string& marker, uint32_t max_entries,
-                    vector<cls_rgw_lc_entry>& entries);
+                    std::vector<cls_rgw_lc_entry>& entries);
 #endif
 
 /* resharding */
index a90c5e103a97a1e6b2ed83c543f72d01039d3b68..c5e252e645a4785d4b2f8e9e0d3042117bf1d308 100644 (file)
@@ -1221,7 +1221,7 @@ struct cls_rgw_lc_list_entries_op {
 WRITE_CLASS_ENCODER(cls_rgw_lc_list_entries_op)
 
 struct cls_rgw_lc_list_entries_ret {
-  vector<cls_rgw_lc_entry> entries;
+  std::vector<cls_rgw_lc_entry> entries;
   bool is_truncated{false};
   uint8_t compat_v;
 
@@ -1231,7 +1231,7 @@ cls_rgw_lc_list_entries_ret(uint8_t compat_v = 3)
   void encode(ceph::buffer::list& bl) const {
     ENCODE_START(compat_v, 1, bl);
     if (compat_v <= 2) {
-      map<string, int> oes;
+      std::map<std::string, int> oes;
       std::for_each(entries.begin(), entries.end(),
                    [&oes](const cls_rgw_lc_entry& elt)
                      {oes.insert({elt.bucket, elt.status});});
@@ -1247,10 +1247,10 @@ cls_rgw_lc_list_entries_ret(uint8_t compat_v = 3)
     DECODE_START(3, bl);
     compat_v = struct_v;
     if (struct_v <= 2) {
-      map<string, int> oes;
+      std::map<std::string, int> oes;
       decode(oes, bl);
       std::for_each(oes.begin(), oes.end(),
-                   [this](const std::pair<string, int>& oe)
+                   [this](const std::pair<std::string, int>& oe)
                      {entries.push_back({oe.first, 0 /* start */,
                                          uint32_t(oe.second)});});
     } else {
index 98c3741863fb90c31a037b92f983a69aaa432951..1a748967bd82e3f548de7fc05b0165cec4cce1ad 100644 (file)
@@ -8,7 +8,7 @@ void cls_timeindex_entry::dump(Formatter *f) const
   f->dump_string("value", value.to_str());
 }
 
-void cls_timeindex_entry::generate_test_instances(list<cls_timeindex_entry*>& o)
+void cls_timeindex_entry::generate_test_instances(std::list<cls_timeindex_entry*>& o)
 {
   cls_timeindex_entry *i = new cls_timeindex_entry;
   i->key_ts = utime_t(0,0);