]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 08:00:32 +0000 (16:00 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:23:38 +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/ceph_syn.cc
src/client/SyntheticClient.cc
src/client/SyntheticClient.h
src/client/fuse_ll.cc
src/include/Distribution.h

index f67f5d5b34ca292d2b2e6f8bd4adaa7b7cd0d705..38268c438e8440c7b613988e1cfde5c7e1cc6ca0 100644 (file)
@@ -34,6 +34,8 @@
 #include <sys/types.h>
 #include <fcntl.h>
 
+using namespace std;
+
 extern int syn_filer_flags;
 
 int main(int argc, const char **argv, char *envp[]) 
index 9ef5ccf19937bf8a5945417d2eb6e7aaf1076b40..3b408dd3f2df85ff8635c0a69b3fcabd1146f125 100644 (file)
@@ -43,6 +43,7 @@
 #undef dout_prefix
 #define dout_prefix *_dout << "client." << (whoami >= 0 ? whoami:client->get_nodeid()) << " "
 
+using namespace std;
 // traces
 //void trace_include(SyntheticClient *syn, Client *cl, string& prefix);
 //void trace_openssh(SyntheticClient *syn, Client *cl, string& prefix);
index faec7e26d8addd0ec69d909752afbd12d255b671..2c160163732e5e1b0534923f6831a85a7a2bf990 100644 (file)
@@ -94,7 +94,7 @@
 
 
 
-void parse_syn_options(vector<const char*>& args);
+void parse_syn_options(std::vector<const char*>& args);
 extern int num_client;
 
 class SyntheticClient {
@@ -109,11 +109,11 @@ class SyntheticClient {
   int get_op();
 
   
-  filepath             cwd;
-  map<string, struct stat*> contents;
-  set<string>          subdirs;
-  bool                 did_readdir;
-  set<int>             open_files;
+  filepath cwd;
+  std::map<std::string, struct stat*> contents;
+  std::set<std::string> subdirs;
+  bool did_readdir;
+  std::set<int> open_files;
 
   void up();
 
@@ -125,7 +125,7 @@ class SyntheticClient {
 
   int get_random_fh() {
     int r = rand() % open_files.size();
-    set<int>::iterator it = open_files.begin();
+    std::set<int>::iterator it = open_files.begin();
     while (r--) ++it;
     return *it;
   }
@@ -135,7 +135,7 @@ class SyntheticClient {
   const char *get_random_subdir() {
     ceph_assert(!subdirs.empty());
     int r = ((rand() % subdirs.size()) + (rand() % subdirs.size())) / 2;  // non-uniform distn
-    set<string>::iterator it = subdirs.begin();
+    std::set<std::string>::iterator it = subdirs.begin();
     while (r--) ++it;
 
     n1 = cwd;
@@ -150,7 +150,7 @@ class SyntheticClient {
       r += cwd.last_dentry().c_str()[0];                                         // slightly permuted
     r %= contents.size();
 
-    map<string,struct stat*>::iterator it = contents.begin();
+    std::map<std::string,struct stat*>::iterator it = contents.begin();
     while (r--) ++it;
 
     n2 = cwd;
@@ -162,7 +162,7 @@ class SyntheticClient {
   char sub_s[50];
   const char *make_sub(const char *base) {
     snprintf(sub_s, sizeof(sub_s), "%s.%d", base, rand() % 100);
-    string f = sub_s;
+    std::string f = sub_s;
     sub = cwd;
     sub.push_dentry(f);
     return sub.c_str();
@@ -191,16 +191,16 @@ class SyntheticClient {
   }
 
   // run() will do one of these things:
-  list<int> modes;
-  list<string> sargs;
-  list<int> iargs;
+  std::list<int> modes;
+  std::list<std::string> sargs;
+  std::list<int> iargs;
   utime_t run_start;
   utime_t run_until;
 
   client_t run_only;
   client_t exclude;
 
-  string get_sarg(int seq);
+  std::string get_sarg(int seq);
   int get_iarg() {
     int i = iargs.front();
     iargs.pop_front();
@@ -209,24 +209,24 @@ class SyntheticClient {
 
   bool time_to_stop() {
     utime_t now = ceph_clock_now();
-    if (0) cout << "time_to_stop .. now " << now
-               << " until " << run_until
-               << " start " << run_start
-               << std::endl;
+    if (0) std::cout << "time_to_stop .. now " << now
+                    << " until " << run_until
+                    << " start " << run_start
+                    << std::endl;
     if (run_until.sec() && now > run_until)
       return true;
     else
       return false;
   }
 
-  string compose_path(string& prefix, char *rest) {
+  std::string compose_path(std::string& prefix, char *rest) {
     return prefix + rest;
   }
 
-  int full_walk(string& fromdir);
+  int full_walk(std::string& fromdir);
   int random_walk(int n);
 
-  int dump_placement(string& fn);
+  int dump_placement(std::string& fn);
 
 
   int make_dirs(const char *basedir, int dirs, int files, int depth);
@@ -238,8 +238,8 @@ class SyntheticClient {
   int create_shared(int num);
   int open_shared(int num, int count);
 
-  int rm_file(string& fn);
-  int write_file(string& fn, int mb, loff_t chunk);
+  int rm_file(std::string& fn);
+  int write_file(std::string& fn, int mb, loff_t chunk);
   int write_fd(int fd, int size, int wrsize);
 
   int write_batch(int nfile, int mb, int chunk);
@@ -249,15 +249,15 @@ class SyntheticClient {
   int object_rw(int nobj, int osize, int wrpc, int overlap, 
                double rskew, double wskew);
 
-  int read_random(string& fn, int mb, int chunk);
-  int read_random_ex(string& fn, int mb, int chunk);
+  int read_random(std::string& fn, int mb, int chunk);
+  int read_random_ex(std::string& fn, int mb, int chunk);
   
   int overload_osd_0(int n, int sie, int wrsize);
   int check_first_primary(int fd);
 
-  int clean_dir(string& basedir);
+  int clean_dir(std::string& basedir);
 
-  int play_trace(Trace& t, string& prefix, bool metadata_only=false);
+  int play_trace(Trace& t, std::string& prefix, bool metadata_only=false);
 
   void make_dir_mess(const char *basedir, int n);
   void foo();
@@ -270,7 +270,7 @@ class SyntheticClient {
                  const UserPerm& perms);
   int lookup_ino(inodeno_t ino, const UserPerm& perms);
 
-  int chunk_file(string &filename);
+  int chunk_file(std::string &filename);
 
   void mksnap(const char *base, const char *name, const UserPerm& perms);
   void rmsnap(const char *base, const char *name, const UserPerm& perms);
index 3dbd0eda0929e6591e13cbb565e13e3e7388720b..c2de8940fb7222a78a2c1b04d2ab8f16bb3f9684 100644 (file)
@@ -53,6 +53,8 @@
 #define MINOR(dev)     ((unsigned int) ((dev) & MINORMASK))
 #define MKDEV(ma,mi)   (((ma) << MINORBITS) | (mi))
 
+using namespace std;
+
 static const ceph::unordered_map<int,int> cephfs_errno_to_system_errno = {
   {CEPHFS_EBLOCKLISTED,    ESHUTDOWN},
   {CEPHFS_EPERM,           EPERM},
index e4f0b30b1299d199461a2fead3ab608e79c43569..56e998757c379333f5d78c0d7f7f3ed2a3a065e9 100644 (file)
@@ -19,8 +19,8 @@
 #include <vector>
 
 class Distribution {
-  vector<float> p;
-  vector<int> v;
+  std::vector<float> p;
+  std::vector<int> v;
 
  public:
   //Distribution() {