]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: replace positional_path parameter with arg_index in get_path() 19722/head
authorsongweibin <song.weibin@zte.com.cn>
Thu, 4 Jan 2018 05:23:28 +0000 (13:23 +0800)
committersongweibin <song.weibin@zte.com.cn>
Thu, 4 Jan 2018 05:23:28 +0000 (13:23 +0800)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/tools/rbd/Utils.cc
src/tools/rbd/Utils.h
src/tools/rbd/action/Export.cc
src/tools/rbd/action/Import.cc
src/tools/rbd/action/Journal.cc
src/tools/rbd/action/MergeDiff.cc

index f631900e3c648d6631ee98d0548fa07679a8fb42..3728d9da8075f5ecdee28c8c92c6247f2e6717b0 100644 (file)
@@ -805,11 +805,14 @@ int get_image_size(const boost::program_options::variables_map &vm,
 }
 
 int get_path(const boost::program_options::variables_map &vm,
-             const std::string &positional_path, std::string *path) {
-  if (!positional_path.empty()) {
-    *path = positional_path;
-  } else if (vm.count(at::PATH)) {
+             size_t *arg_index, std::string *path) {
+  if (vm.count(at::PATH)) {
     *path = vm[at::PATH].as<std::string>();
+  } else {
+    *path = get_positional_argument(vm, *arg_index);
+    if (!path->empty()) {
+      ++(*arg_index);
+    }
   }
 
   if (path->empty()) {
index fe7538315cc48d9c1e74304d2cece7c39a91ed9c..4c46755303fd83442a1867876d7aeb97d7f801d7 100644 (file)
@@ -161,7 +161,7 @@ int get_image_size(const boost::program_options::variables_map &vm,
                    uint64_t *size);
 
 int get_path(const boost::program_options::variables_map &vm,
-             const std::string &positional_path, std::string *path);
+             size_t *arg_index, std::string *path);
 
 int get_formatter(const boost::program_options::variables_map &vm,
                   argument_types::Format::Formatter *formatter);
index 0fa0eb07ac16f048208d176213a961a01484c081..de7d4c75f57d1e5134d6bf15d112f2e59c0302ae 100644 (file)
@@ -262,7 +262,7 @@ int execute_diff(const po::variables_map &vm) {
   }
 
   std::string path;
-  r = utils::get_path(vm, utils::get_positional_argument(vm, 1), &path);
+  r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }
@@ -601,7 +601,7 @@ int execute(const po::variables_map &vm) {
   }
 
   std::string path;
-  r = utils::get_path(vm, utils::get_positional_argument(vm, 1), &path);
+  r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }
index c25a93344723752bc78125cbda7bf4890cfe57cb..e47eb325f6fda3f265af1906ed06f5e3b2f6f15e 100644 (file)
@@ -443,12 +443,12 @@ void get_arguments_diff(po::options_description *positional,
 
 int execute_diff(const po::variables_map &vm) {
   std::string path;
-  int r = utils::get_path(vm, utils::get_positional_argument(vm, 0), &path);
+  size_t arg_index = 0;
+  int r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }
 
-  size_t arg_index = 1;
   std::string pool_name;
   std::string image_name;
   std::string snap_name;
@@ -906,7 +906,8 @@ void get_arguments(po::options_description *positional,
 
 int execute(const po::variables_map &vm) {
   std::string path;
-  int r = utils::get_path(vm, utils::get_positional_argument(vm, 0), &path);
+  size_t arg_index = 0;
+  int r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }
@@ -941,7 +942,6 @@ int execute(const po::variables_map &vm) {
     sparse_size = vm[at::IMAGE_SPARSE_SIZE].as<size_t>();
   }
 
-  size_t arg_index = 1;
   std::string pool_name = deprecated_pool_name;
   std::string image_name;
   std::string snap_name = deprecated_snap_name;
index 3485dc1f975a5da68517c615549b6a5f2250483f..9b047a4cd935b8213f20a405ee86878307b361b6 100644 (file)
@@ -1000,7 +1000,7 @@ int execute_export(const po::variables_map &vm) {
   }
 
   std::string path;
-  r = utils::get_path(vm, utils::get_positional_argument(vm, 1), &path);
+  r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }
@@ -1032,12 +1032,12 @@ void get_import_arguments(po::options_description *positional,
 
 int execute_import(const po::variables_map &vm) {
   std::string path;
-  int r = utils::get_path(vm, utils::get_positional_argument(vm, 0), &path);
+  size_t arg_index = 0;
+  int r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }
 
-  size_t arg_index = 1;
   std::string pool_name;
   std::string journal_name;
   r = utils::get_pool_journal_names(vm, at::ARGUMENT_MODIFIER_DEST,
index 8d586e756f24e97d56095190dd68d347ca8e3b7e..9be899b081993cb314e93588cad9b8653249f4d0 100644 (file)
@@ -428,8 +428,8 @@ int execute(const po::variables_map &vm) {
   }
 
   std::string path;
-  int r = utils::get_path(vm, utils::get_positional_argument(vm, 2),
-                          &path);
+  size_t arg_index = 2;
+  int r = utils::get_path(vm, &arg_index, &path);
   if (r < 0) {
     return r;
   }