]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd/action: fix error getting positional argument
authorsongweibin <song.weibin@zte.com.cn>
Thu, 30 May 2019 11:58:03 +0000 (19:58 +0800)
committerJason Dillaman <dillaman@redhat.com>
Wed, 24 Jul 2019 21:42:52 +0000 (17:42 -0400)
Fixes: http://tracker.ceph.com/issues/40095
Signed-off-by: songweibin <song.weibin@zte.com.cn>
(cherry picked from commit 32a044b0911aef248aec4f6dda6171693b7c9280)

Conflicts:
src/tools/rbd/action/Config.cc: DNE in Luminous

src/tools/rbd/action/ImageMeta.cc
src/tools/rbd/action/Lock.cc

index c0ae0b8ef1f5dba46d2baa3df89475db5e5263af..61a5c0d0734a850f28c17e700b4455905df06834 100644 (file)
@@ -244,7 +244,7 @@ int execute_set(const po::variables_map &vm) {
     return r;
   }
 
-  std::string value = utils::get_positional_argument(vm, 2);
+  std::string value = utils::get_positional_argument(vm, arg_index);
   if (value.empty()) {
     std::cerr << "rbd: metadata value was not specified" << std::endl;
     return -EINVAL;
index 60d63e8efd21cbc703baee254e86824fad5bdcf6..c41d5e1055a3a610176864fff07ea78d1a8af475 100644 (file)
@@ -24,11 +24,14 @@ void add_id_option(po::options_description *positional) {
     ("lock-id", "unique lock id");
 }
 
-int get_id(const po::variables_map &vm, std::string *id) {
-  *id = utils::get_positional_argument(vm, 1);
+int get_id(const po::variables_map &vm, size_t *arg_index,
+           std::string *id) {
+  *id = utils::get_positional_argument(vm, *arg_index);
   if (id->empty()) {
     std::cerr << "rbd: lock id was not specified" << std::endl;
     return -EINVAL;
+  } else {
+    ++(*arg_index);
   }
   return 0;
 }
@@ -165,7 +168,7 @@ int execute_add(const po::variables_map &vm) {
   }
 
   std::string lock_cookie;
-  r = get_id(vm, &lock_cookie);
+  r = get_id(vm, &arg_index, &lock_cookie);
   if (r < 0) {
     return r;
   }
@@ -223,12 +226,12 @@ int execute_remove(const po::variables_map &vm) {
   }
 
   std::string lock_cookie;
-  r = get_id(vm, &lock_cookie);
+  r = get_id(vm, &arg_index, &lock_cookie);
   if (r < 0) {
     return r;
   }
 
-  std::string lock_client = utils::get_positional_argument(vm, 2);
+  std::string lock_client = utils::get_positional_argument(vm, arg_index);
   if (lock_client.empty()) {
     std::cerr << "rbd: locker was not specified" << std::endl;
     return -EINVAL;