]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 10:44:08 +0000 (18:44 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:23:39 +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>
13 files changed:
src/tools/cephfs/DataScan.cc
src/tools/cephfs/DataScan.h
src/tools/cephfs/Dumper.cc
src/tools/cephfs/JournalFilter.cc
src/tools/cephfs/JournalTool.cc
src/tools/cephfs/MetaTool.cc
src/tools/cephfs/MetaTool.h
src/tools/cephfs/Resetter.cc
src/tools/cephfs/TableTool.cc
src/tools/cephfs/cephfs-data-scan.cc
src/tools/cephfs/cephfs-journal-tool.cc
src/tools/cephfs/cephfs-table-tool.cc
src/tools/cephfs/type_helper.hpp

index 649e96b15ad3fcdacdbb2ef9371c22d71d08d66f..dd2e4417e09ba2d7b1544c1008c33f1de263dada 100644 (file)
@@ -35,6 +35,8 @@
 #undef dout_prefix
 #define dout_prefix *_dout << "datascan." << __func__ << ": "
 
+using namespace std;
+
 void DataScan::usage()
 {
   std::cout << "Usage: \n"
index 5c87fe2bdec4a89a169209ba49445f8e3964d5be..fe997f66325149ad1a5d189de7f302431f136dbd 100644 (file)
@@ -244,7 +244,7 @@ class DataScan : public MDSUtility, public MetadataTool
     RecoveryDriver *driver;
     fs_cluster_id_t fscid;
 
-    string metadata_pool_name;
+    std::string metadata_pool_name;
     std::vector<int64_t> data_pools;
 
     // IoCtx for data pool (where we scrape file backtraces from)
@@ -291,7 +291,7 @@ class DataScan : public MDSUtility, public MetadataTool
     // Overwrite root objects even if they exist
     bool force_init;
     // Only scan inodes without this scrub tag
-    string filter_tag;
+    std::string filter_tag;
 
     /**
      * @param r set to error on valid key with invalid value
index f3b07c55181413e9bb5f4c397511a6e7bac14619..68a190182dd03cc11892e0640117f4cb24a8fd60 100644 (file)
@@ -34,6 +34,8 @@
 
 #define HEADER_LEN 4096
 
+using namespace std;
+
 int Dumper::init(mds_role_t role_, const std::string &type)
 {
   role = role_;
index 266d7fccb578d8c807dab51fd7ad14e329cf069f..3a5e781a2db68da74a140b84d69d190c88819c18 100644 (file)
@@ -22,6 +22,7 @@
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_mds
 
+using namespace std;
 
 const string JournalFilter::range_separator("..");
 
index ec98609803a46a3998f44efae380440a2f9592aa..d972f8341f6682b8de71ac27ad58c8071c225255 100644 (file)
@@ -37,7 +37,7 @@
 #undef dout_prefix
 #define dout_prefix *_dout << __func__ << ": "
 
-
+using namespace std;
 
 void JournalTool::usage()
 {
index 527ae636fc0ffd247fb9788ba761cb391a788795..baa0d498a2aa1a2e0e8fb119ff93f1c9d0b9db30 100644 (file)
@@ -37,6 +37,7 @@ WRITE_RAW_ENCODER(unsigned char)
 #undef dout_prefix
 #define dout_prefix *_dout << __func__ << ": "
 
+using namespace std;
 
 void MetaTool::meta_op::release()
 {
index 510be6552a874a177e93ff63ed291d562eceaef0..d36f7bba23c0118ae5c714f530127ff249921e9e 100644 (file)
@@ -46,7 +46,7 @@ public:
 private:
   class meta_op {
   public:
-    meta_op(bool debug = false, string out = "", string in = "", bool confirm = false):
+    meta_op(bool debug = false, std::string out = "", std::string in = "", bool confirm = false):
         _debug(debug),
         _out(out),
         _in(in),
@@ -68,8 +68,8 @@ private:
       INO_F
     } ino_type;
 
-    static string op_type_name(op_type& t) {
-      string name;
+    static std::string op_type_name(op_type& t) {
+      std::string name;
       switch (t) {
       case OP_LIST:
         name = "list dir";
@@ -97,8 +97,8 @@ private:
       }
       return name;
     }
-    static string ino_type_name(ino_type& t) {
-      string name;
+    static std::string ino_type_name(ino_type& t) {
+      std::string name;
       switch (t) {
       case INO_DIR:
         name = "dir";
@@ -121,7 +121,7 @@ private:
       void print() {
         std::cout << detail() << std::endl;
       }
-      string detail() {
+      std::string detail() {
         std::stringstream ds;
         ds << " [sub_op]" << op_type_name(sub_op_t) << "|"
            << ino_type_name(sub_ino_t) << "|"
@@ -165,7 +165,7 @@ private:
       
     std::map<inodeno_t, inode_backpointer_t > ancestors;
     std::map<inodeno_t, inode_meta_t* > inodes;
-    std::map<inodeno_t, string > okeys;
+    std::map<inodeno_t, std::string > okeys;
       
     void clear_sops() {
       while(!no_sops())
@@ -189,10 +189,10 @@ private:
       delete sop;
       sub_ops.pop();
     }
-    string outfile() {
+    std::string outfile() {
       return _out;
     }
-    string infile() {
+    std::string infile() {
       return _in;
     }
     bool is_debug() {
@@ -204,8 +204,8 @@ private:
   private:
     stack<sub_op*> sub_ops;
     bool _debug;
-    string _out;
-    string _in;
+    std::string _out;
+    std::string _in;
     bool _confirm;
   };
   MDSRoleSelector role_selector;
@@ -236,12 +236,12 @@ private:
                  meta_op* op = NULL
                  );
 
-  int process(string& mode, string& ino, string out, string in, bool confirm);
-  int show_meta_info(string& ino, string& out);
-  int list_meta_info(string& ino, string& out);
-  int amend_meta_info(string& ino, string& in, bool confirm);
-  int show_fnode(string& ino, string& out);
-  int amend_fnode(string& in, bool confirm);
+  int process(std::string& mode, std::string& ino, std::string out, std::string in, bool confirm);
+  int show_meta_info(std::string& ino, std::string& out);
+  int list_meta_info(std::string& ino, std::string& out);
+  int amend_meta_info(std::string& ino, std::string& in, bool confirm);
+  int show_fnode(std::string& ino, std::string& out);
+  int amend_fnode(std::string& in, bool confirm);
   int op_process(meta_op &op);
   int list_meta(meta_op &op);
   int file_meta(meta_op &op);
@@ -251,21 +251,21 @@ private:
   int amend_fn(meta_op &op);
   public:
   int _file_meta(meta_op &op, librados::IoCtx& io);
-  int _show_meta(inode_meta_t& i, const string& fn);
-  int _amend_meta(string &k, inode_meta_t& i, const string& fn, meta_op& op);
-  int _show_fn(inode_meta_t& i, const string& fn);
-  int _amend_fn(const string& fn, bool confirm);
+  int _show_meta(inode_meta_t& i, const std::string& fn);
+  int _amend_meta(std::string &k, inode_meta_t& i, const std::string& fn, meta_op& op);
+  int _show_fn(inode_meta_t& i, const std::string& fn);
+  int _amend_fn(const std::string& fn, bool confirm);
   void usage();
   MetaTool(bool debug=false):
       _debug(debug) {}
   ~MetaTool() {}
 
-  int main(string& mode,
-           string& rank_str,
-           string& minfo,
-           string&ino,
-           string& out,
-           string& in,
+  int main(std::string& mode,
+           std::string& rank_str,
+           std::string& minfo,
+           std::string&ino,
+           std::string& out,
+           std::string& in,
            bool confirm = false
            );
 };
index 278a48767cdfd0f73090e5532b2a4eeb5780a788..7c0aa30ab6a88acf92c1c83a620034eaf76dcd34 100644 (file)
@@ -26,6 +26,8 @@
 #define dout_context g_ceph_context
 #define dout_subsys ceph_subsys_mds
 
+using namespace std;
+
 int Resetter::init(mds_role_t role_, const std::string &type, bool hard)
 {
   role = role_;
index e779b4b665e9dc4673da2bbfaedb45fd08c0f802..dcd35a6241b7e5bcda4da685e2e229679881d2ad 100644 (file)
@@ -27,6 +27,8 @@
 #undef dout_prefix
 #define dout_prefix *_dout << __func__ << ": "
 
+using namespace std;
+
 void TableTool::usage()
 {
   std::cout << "Usage: \n"
index e6efff66c370b32bf30b702346a194930855b9f5..f8241823f5c28736ac82c2e4e43b250e09d5768e 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "DataScan.h"
 
+using namespace std;
 
 int main(int argc, const char **argv)
 {
index 290cb305ba5274d38f442ce5b27023eff9a85ca8..1de11209bbdb8153a5e1a7c2d9db27b4eccd3bdf 100644 (file)
 
 int main(int argc, const char **argv)
 {
-  vector<const char*> args;
+  std::vector<const char*> args;
   argv_to_vec(argc, argv, args);
   if (args.empty()) {
-    cerr << argv[0] << ": -h or --help for usage" << std::endl;
+    std::cerr << argv[0] << ": -h or --help for usage" << std::endl;
     exit(1);
   }
   if (ceph_argparse_need_usage(args)) {
index 47b475dd0f89b8cab920d3cbc66fd117db992340..120b4b3576baa8575f13658587e1fbaece9e05ef 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "TableTool.h"
 
+using namespace std;
 
 int main(int argc, const char **argv)
 {
index 06dfa0afe5e6bc279ad0c05910087d47673077ff..2ec77c25cd74fafef6141d96dd957dd007f5e8ee 100644 (file)
@@ -10,7 +10,7 @@ T1 conv_t(T2 s){
     return target;
 }
 
-void string_split(std::string str, vector<string>& out, string split = ":"){
+void string_split(std::string str, std::vector<std::string>& out, std::string split = ":") {
     std::cout << str << std::endl;
     auto pos = str.find(split);
     while(pos != std::string::npos){