]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virsh: improve option handling
authorEric Blake <eblake@redhat.com>
Fri, 15 Jul 2011 17:23:17 +0000 (11:23 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 15 Jul 2011 21:58:51 +0000 (15:58 -0600)
commitca92c85756f27920cc6aa566278437abad628e9e
tree6eacac24d8d28584a3e05ffcc9b200d84728cad1
parent20135c704ab5a7139174f64a435ab7a2c2ed02df
virsh: improve option handling

The documentation for vshCommandOptString claims that it returns
-1 on a missing required argument, but in reality, that error
message was unreachable (it was buried inside an if clause that
is true only if the argument was present).  The code was so hairy
that I decided a rewrite would make it easier to understand,
and actually return the error values we want.

Meanwhile, our construction guarantees that all vshCmdOpt have
a non-null def member, so there are some redundant checks that
can be trimmed.

* tools/virsh.c (vshCommandOpt): Alter signature.
(vshCommandOptInt, vshCommandOptUInt, vshCommandOptUL)
(vshCommandOptString, vshCommandOptLongLong)
(vshCommandOptULongLong, vshCommandOptBool): Adjust all callers.
(vshCommandOptArgv): Remove dead condition.
tools/virsh.c