[libvirt] [PATCH] virsh: improve option handling

Matthias Bolte matthias.bolte at googlemail.com
Fri Jul 15 19:28:32 UTC 2011


2011/7/15 Eric Blake <eblake at redhat.com>:
> 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.  In the process,
> this guarantees that --option '' will either return -1 or 1,
> depending on whether EMPTY_OK was set, reserving 0 solely
> for the case of an option not present and not required.
>
> 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.
> ---
>
> This patch replaces the one mentioned here:
> https://www.redhat.com/archives/libvir-list/2011-July/msg00995.html
>
>  tools/virsh.c |  302 +++++++++++++++++++++++++++++++++++++++------------------
>  1 files changed, 206 insertions(+), 96 deletions(-)

Looks good, ACK.

-- 
Matthias Bolte
http://photron.blogspot.com




More information about the libvir-list mailing list