Re: [PATCH] virsh: improve option handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/15/2011 01:28 PM, Matthias Bolte wrote:
2011/7/15 Eric Blake<eblake@xxxxxxxxxx>:
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.

Thanks; pushed.

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]