Re: [PATCH 3/8] virsh-host: Refactor cmdFreecell

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

 



On 03/21/13 04:48, Eric Blake wrote:
On 03/07/2013 05:53 AM, Peter Krempa wrote:
Use the new helpers to determine mutually exclusive options and touch up
some parts to simplify the code.
---
  tools/virsh-host.c | 55 +++++++++++++++++++++++-------------------------------
  1 file changed, 23 insertions(+), 32 deletions(-)


-    if ((cell_given = vshCommandOptInt(cmd, "cellno", &cell)) < 0) {
-        vshError(ctl, "%s", _("cell number has to be a number"));
-        goto cleanup;
-    }
-    all_given = vshCommandOptBool(cmd, "all");
+    VSH_EXCLUSIVE_OPTIONS_VAR(all, cellno);

-    if (all_given && cell_given) {
-        vshError(ctl, "%s", _("--cellno and --all are mutually exclusive. "
-                              "Please choose only one."));
-        goto cleanup;
+    if (cellno && vshCommandOptInt(cmd, "cellno", &cell) < 0) {

The 'cellno &&' portion is extra; we didn't need it before, so I don't
know why you added it here.  vshCommandOptInt returns 0 if --cellno was
not provided, since it is not a mandatory option.

I used it there to avoid the call to vshCommandOptInt in case it won't parse anything as the cellno parameter is missing anyways. It is not strictly needed but it's a optimization so I'll leave it in.


ACK if you either explain the added conjunct or remove it, and if you
fix the whitespace.


Peter

--
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]