From: songweibin Date: Mon, 19 Nov 2018 11:23:51 +0000 (+0800) Subject: rbd: fix error parse arg when getting config key X-Git-Tag: v14.1.0~848^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=93ab2d4959941118fc6dcc63739be85ce7fbd4df;p=ceph.git rbd: fix error parse arg when getting config key Signed-off-by: songweibin --- diff --git a/src/tools/rbd/action/Config.cc b/src/tools/rbd/action/Config.cc index 0f1932d3bfc9..40093172ff84 100644 --- a/src/tools/rbd/action/Config.cc +++ b/src/tools/rbd/action/Config.cc @@ -71,11 +71,14 @@ int get_pool(const po::variables_map &vm, std::string *pool_name) { return 0; } -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: config key was not specified" << std::endl; return -EINVAL; + } else { + ++(*arg_index); } if (!boost::starts_with(*key, "rbd_")) { @@ -203,7 +206,8 @@ int execute_global_get(const po::variables_map &vm, } std::string key; - r = get_key(vm, &key); + size_t arg_index = 1; + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; } @@ -248,7 +252,8 @@ int execute_global_set(const po::variables_map &vm, } std::string key; - r = get_key(vm, &key); + size_t arg_index = 1; + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; } @@ -294,7 +299,8 @@ int execute_global_remove( } std::string key; - r = get_key(vm, &key); + size_t arg_index = 1; + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; } @@ -406,7 +412,8 @@ int execute_pool_get(const po::variables_map &vm, } std::string key; - r = get_key(vm, &key); + size_t arg_index = 1; + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; } @@ -453,7 +460,8 @@ int execute_pool_set(const po::variables_map &vm, } std::string key; - r = get_key(vm, &key); + size_t arg_index = 1; + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; } @@ -493,7 +501,8 @@ int execute_pool_remove(const po::variables_map &vm, } std::string key; - r = get_key(vm, &key); + size_t arg_index = 1; + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; } @@ -607,7 +616,7 @@ int execute_image_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; } @@ -662,7 +671,7 @@ int execute_image_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; } @@ -711,7 +720,7 @@ int execute_image_remove( } std::string key; - r = get_key(vm, &key); + r = get_key(vm, &arg_index, &key); if (r < 0) { return r; }