]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
rbd: bail if too many arguments provided 6738/head
authorIlya Dryomov <idryomov@gmail.com>
Sun, 29 Nov 2015 20:46:41 +0000 (21:46 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 30 Nov 2015 16:50:10 +0000 (17:50 +0100)
commit9d0604149e0fe8ddd24109fa4ef0d8ec670629f5
treee34c2d7701ac73e80ca9b276398de7a31fffd3e0
parentd133f423c8efb3390f3ef8dc3ee01a18cd6a3d93
rbd: bail if too many arguments provided

The code has a catch clause for that, but it was being rendered useless
by the preceding

    if (command_spec.size() > matching_spec->size())
      positional_options.add(at::POSITIONAL_ARGUMENTS.c_str(), -1);

which names all (both expected and extraneous) positional arguments.

Change it to name only expected arguments, deriving the number of
expected arguments from the length of positional_opts vector, supplied
by each action.  This works for all actions except "feature enable" and
"feature disable" which are specified as multitoken, so keep on passing
in -1 for those.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/test/cli/rbd/too-many-args.t [new file with mode: 0644]
src/tools/rbd/Shell.cc