From: songweibin Date: Mon, 19 Nov 2018 11:26:41 +0000 (+0800) Subject: rbd: fix error parse arg when getting image-meta key X-Git-Tag: v14.1.0~848^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ddec748d087f6effa782c21f7730f02bd92f778;p=ceph.git rbd: fix error parse arg when getting image-meta key Signed-off-by: songweibin --- diff --git a/src/tools/rbd/action/ImageMeta.cc b/src/tools/rbd/action/ImageMeta.cc index f5804de7263..1ea7413d154 100644 --- a/src/tools/rbd/action/ImageMeta.cc +++ b/src/tools/rbd/action/ImageMeta.cc @@ -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; }