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. -- Matthias Bolte http://photron.blogspot.com -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list