]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix error parse arg when getting image-meta key 25152/head
authorsongweibin <song.weibin@zte.com.cn>
Mon, 19 Nov 2018 11:26:41 +0000 (19:26 +0800)
committersongweibin <song.weibin@zte.com.cn>
Mon, 19 Nov 2018 11:27:51 +0000 (19:27 +0800)
Signed-off-by: songweibin <song.weibin@zte.com.cn>
src/tools/rbd/action/ImageMeta.cc

index f5804de7263281634505d250e7eb6b3d3cde70c3..1ea7413d154341ad774fab4eabc01671d832af83 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;
 }
@@ -201,7 +204,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;
   }
@@ -248,7 +251,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;
   }
@@ -299,7 +302,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;
   }