]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix error parse arg when getting image-meta key 29295/head
authorsongweibin <song.weibin@zte.com.cn>
Mon, 19 Nov 2018 11:26:41 +0000 (19:26 +0800)
committerJason Dillaman <dillaman@redhat.com>
Thu, 25 Jul 2019 14:07:23 +0000 (10:07 -0400)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
(cherry picked from commit 3ddec748d087f6effa782c21f7730f02bd92f778)

src/tools/rbd/action/ImageMeta.cc

index 61a5c0d0734a850f28c17e700b4455905df06834..58000c82f15feae75a629fa9635ab9c1e134374a 100644 (file)
@@ -24,11 +24,14 @@ void add_key_option(po::options_description *positional) {
     ("key", "image meta key");
 }
 
-int get_key(const po::variables_map &vm, std::string *key) {
-  *key = utils::get_positional_argument(vm, 1);
+int get_key(const po::variables_map &vm, size_t *arg_index,
+            std::string *key) {
+  *key = utils::get_positional_argument(vm, *arg_index);
   if (key->empty()) {
     std::cerr << "rbd: metadata key was not specified" << std::endl;
     return -EINVAL;
+  } else {
+    ++(*arg_index);
   }
   return 0;
 }
@@ -195,7 +198,7 @@ int execute_get(const po::variables_map &vm) {
   }
 
   std::string key;
-  r = get_key(vm, &key);
+  r = get_key(vm, &arg_index, &key);
   if (r < 0) {
     return r;
   }
@@ -239,7 +242,7 @@ int execute_set(const po::variables_map &vm) {
   }
 
   std::string key;
-  r = get_key(vm, &key);
+  r = get_key(vm, &arg_index, &key);
   if (r < 0) {
     return r;
   }
@@ -287,7 +290,7 @@ int execute_remove(const po::variables_map &vm) {
   }
 
   std::string key;
-  r = get_key(vm, &key);
+  r = get_key(vm, &arg_index, &key);
   if (r < 0) {
     return r;
   }