]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:54:10 +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>
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/RadosClient.cc
src/librados/RadosClient.h
src/librados/librados_c.cc
src/librados/librados_cxx.cc
src/librados/snap_set_diff.cc

index 25edd35337b160179bdee4a9c10138a3972ccdc0..363ac7ee6d568dec6468f6cdab1495c83a07fc2b 100644 (file)
 #undef dout_prefix
 #define dout_prefix *_dout << "librados: "
 
+using std::string;
+using std::map;
+using std::unique_lock;
+using std::vector;
+
 namespace bs = boost::system;
 namespace ca = ceph::async;
 namespace cb = ceph::buffer;
index bd887bf210acf02344a1454df3e969940258678e..4fb4e621c1cd8a83a3c2a82d9b5d970e834e9522 100644 (file)
@@ -47,7 +47,7 @@ struct librados::IoCtxImpl {
   ceph_tid_t aio_write_seq = 0;
   ceph::condition_variable aio_write_cond;
   xlist<AioCompletionImpl*> aio_write_list;
-  map<ceph_tid_t, std::list<AioCompletionImpl*> > aio_write_waiters;
+  std::map<ceph_tid_t, std::list<AioCompletionImpl*> > aio_write_waiters;
 
   Objecter *objecter = nullptr;
 
@@ -69,7 +69,7 @@ struct librados::IoCtxImpl {
   }
 
   void set_snap_read(snapid_t s);
-  int set_snap_write_context(snapid_t seq, vector<snapid_t>& snaps);
+  int set_snap_write_context(snapid_t seq, std::vector<snapid_t>& snaps);
 
   void get() {
     ref_cnt++;
@@ -89,7 +89,7 @@ struct librados::IoCtxImpl {
     return poolid;
   }
 
-  string get_cached_pool_name();
+  std::string get_cached_pool_name();
 
   int get_object_hash_position(const std::string& oid, uint32_t *hash_position);
   int get_object_pg_hash_position(const std::string& oid, uint32_t *pg_hash_position);
@@ -97,7 +97,7 @@ struct librados::IoCtxImpl {
   ::ObjectOperation *prepare_assert_ops(::ObjectOperation *op);
 
   // snaps
-  int snap_list(vector<uint64_t> *snaps);
+  int snap_list(std::vector<uint64_t> *snaps);
   int snap_lookup(const char *name, uint64_t *snapid);
   int snap_get_name(uint64_t snapid, std::string *s);
   int snap_get_stamp(uint64_t snapid, time_t *t);
@@ -150,7 +150,7 @@ struct librados::IoCtxImpl {
 
   int getxattr(const object_t& oid, const char *name, bufferlist& bl);
   int setxattr(const object_t& oid, const char *name, bufferlist& bl);
-  int getxattrs(const object_t& oid, map<string, bufferlist>& attrset);
+  int getxattrs(const object_t& oid, std::map<std::string, bufferlist>& attrset);
   int rmxattr(const object_t& oid, const char *name);
 
   int operate(const object_t& oid, ::ObjectOperation *o, ceph::real_time *pmtime, int flags=0);
@@ -220,7 +220,7 @@ struct librados::IoCtxImpl {
   int aio_setxattr(const object_t& oid, AioCompletionImpl *c,
                   const char *name, bufferlist& bl);
   int aio_getxattrs(const object_t& oid, AioCompletionImpl *c,
-                   map<string, bufferlist>& attrset);
+                   std::map<std::string, bufferlist>& attrset);
   int aio_rmxattr(const object_t& oid, AioCompletionImpl *c,
                  const char *name);
   int aio_cancel(AioCompletionImpl *c);
index 631067474054bb313721b51bd6f1fef56d9b72b1..3d4563c8bf1e6f1edfd671ae22d628d91d5f2ab5 100644 (file)
 #undef dout_prefix
 #define dout_prefix *_dout << "librados: "
 
+using std::ostringstream;
+using std::string;
+using std::map;
+using std::vector;
+
 namespace bc = boost::container;
 namespace bs = boost::system;
 namespace ca = ceph::async;
index df339772510ad6f61929fb5ef3602a28c60df911..00a273b82d30dab7486c9a969b81c5e5993d7372 100644 (file)
@@ -86,11 +86,11 @@ private:
   rados_log_callback_t log_cb{nullptr};
   rados_log_callback2_t log_cb2{nullptr};
   void *log_cb_arg{nullptr};
-  string log_watch;
+  std::string log_watch;
 
   bool service_daemon = false;
-  string daemon_name, service_name;
-  map<string,string> daemon_metadata;
+  std::string daemon_name, service_name;
+  std::map<std::string,std::string> daemon_metadata;
   ceph::timespan rados_mon_op_timeout{};
 
   int wait_for_osdmap();
@@ -127,8 +127,8 @@ public:
   int pool_get_name(uint64_t pool_id, std::string *name,
                    bool wait_latest_map = false);
 
-  int pool_list(std::list<std::pair<int64_t, string> >& ls);
-  int get_pool_stats(std::list<string>& ls, map<string,::pool_stat_t> *result,
+  int pool_list(std::list<std::pair<int64_t, std::string> >& ls);
+  int get_pool_stats(std::list<std::string>& ls, std::map<std::string,::pool_stat_t> *result,
     bool *per_pool);
   int get_fs_stats(ceph_statfs& result);
   bool get_pool_is_selfmanaged_snaps_mode(const std::string& pool);
@@ -139,39 +139,39 @@ public:
     b) the first rule
     c) error out if no value find
   */
-  int pool_create(string& name, int16_t crush_rule=-1);
-  int pool_create_async(string& name, PoolAsyncCompletionImpl *c,
+  int pool_create(std::string& name, int16_t crush_rule=-1);
+  int pool_create_async(std::string& name, PoolAsyncCompletionImpl *c,
                        int16_t crush_rule=-1);
   int pool_get_base_tier(int64_t pool_id, int64_t* base_tier);
   int pool_delete(const char *name);
 
   int pool_delete_async(const char *name, PoolAsyncCompletionImpl *c);
 
-  int blocklist_add(const string& client_address, uint32_t expire_seconds);
+  int blocklist_add(const std::string& client_address, uint32_t expire_seconds);
 
-  int mon_command(const vector<string>& cmd, const bufferlist &inbl,
-                 bufferlist *outbl, string *outs);
-  void mon_command_async(const vector<string>& cmd, const bufferlist &inbl,
-                         bufferlist *outbl, string *outs, Context *on_finish);
+  int mon_command(const std::vector<std::string>& cmd, const bufferlist &inbl,
+                 bufferlist *outbl, std::string *outs);
+  void mon_command_async(const std::vector<std::string>& cmd, const bufferlist &inbl,
+                         bufferlist *outbl, std::string *outs, Context *on_finish);
   int mon_command(int rank,
-                 const vector<string>& cmd, const bufferlist &inbl,
-                 bufferlist *outbl, string *outs);
-  int mon_command(string name,
-                 const vector<string>& cmd, const bufferlist &inbl,
-                 bufferlist *outbl, string *outs);
-  int mgr_command(const vector<string>& cmd, const bufferlist &inbl,
-                 bufferlist *outbl, string *outs);
+                 const std::vector<std::string>& cmd, const bufferlist &inbl,
+                 bufferlist *outbl, std::string *outs);
+  int mon_command(std::string name,
+                 const std::vector<std::string>& cmd, const bufferlist &inbl,
+                 bufferlist *outbl, std::string *outs);
+  int mgr_command(const std::vector<std::string>& cmd, const bufferlist &inbl,
+                 bufferlist *outbl, std::string *outs);
   int mgr_command(
-    const string& name,
-    const vector<string>& cmd, const bufferlist &inbl,
-    bufferlist *outbl, string *outs);
-  int osd_command(int osd, vector<string>& cmd, const bufferlist& inbl,
-                  bufferlist *poutbl, string *prs);
-  int pg_command(pg_t pgid, vector<string>& cmd, const bufferlist& inbl,
-                bufferlist *poutbl, string *prs);
+    const std::string& name,
+    const std::vector<std::string>& cmd, const bufferlist &inbl,
+    bufferlist *outbl, std::string *outs);
+  int osd_command(int osd, std::vector<std::string>& cmd, const bufferlist& inbl,
+                  bufferlist *poutbl, std::string *prs);
+  int pg_command(pg_t pgid, std::vector<std::string>& cmd, const bufferlist& inbl,
+                bufferlist *poutbl, std::string *prs);
 
   void handle_log(MLog *m);
-  int monitor_log(const string& level, rados_log_callback_t cb,
+  int monitor_log(const std::string& level, rados_log_callback_t cb,
                  rados_log_callback2_t cb2, void *arg);
 
   void get();
index b56732b1a95aaeb5f2ac5f230e85cb02f72b2b4b..edef71f1b27f1444e73fd6bb3094588b77a7e89a 100644 (file)
@@ -80,6 +80,8 @@
 #define LIBRADOS_C_API_DEFAULT_F(fn) fn
 #endif
 
+using std::ostringstream;
+using std::pair;
 using std::string;
 using std::map;
 using std::set;
index ad712506b66e694e0ea00267da8263b9b8586d0f..85f3b92137f56644884ad59976b4af04a77d6117 100644 (file)
 #define tracepoint(...)
 #endif
 
-using std::string;
+using std::list;
 using std::map;
+using std::pair;
 using std::set;
+using std::string;
+using std::stringstream;
 using std::vector;
-using std::list;
 
 #define dout_subsys ceph_subsys_rados
 #undef dout_prefix
index b42ad9bcd5519ebd91b1b47a097adf38b8bdc27d..06f76b02345f0909740e1e8b7ec95e82211b9d5a 100644 (file)
@@ -11,6 +11,7 @@
 
 #define dout_subsys ceph_subsys_rados
 
+using namespace std;
 /**
  * calculate intervals/extents that vary between two snapshots
  */