We have macros that check and reject mutually exclusive
parameters to our commands. Use those instead of if-else tree.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-network.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/tools/virsh-network.c b/tools/virsh-network.c
index 1ae206a..d0bd7a3 100644
--- a/tools/virsh-network.c
+++ b/tools/virsh-network.c
@@ -907,9 +907,12 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
bool current = vshCommandOptBool(cmd, "current");
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
- unsigned int flags = 0;
+ unsigned int flags = VIR_NETWORK_UPDATE_AFFECT_CURRENT;
const char *affected;
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
+ VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
+
if (!(network = virshCommandOptNetwork(ctl, cmd, NULL)))
return false;
@@ -962,18 +965,10 @@ cmdNetworkUpdate(vshControl *ctl, const vshCmd *cmd)
xml = xmlFromFile;
}
- if (current) {
- if (live || config) {
- vshError(ctl, "%s", _("--current must be specified
exclusively"));
- goto cleanup;
- }
- flags |= VIR_NETWORK_UPDATE_AFFECT_CURRENT;
- } else {
- if (config)
- flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
- if (live)
- flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
- }
+ if (config)
+ flags |= VIR_NETWORK_UPDATE_AFFECT_CONFIG;
+ if (live)
+ flags |= VIR_NETWORK_UPDATE_AFFECT_LIVE;
if (virNetworkUpdate(network, command,
section, parentIndex, xml, flags) < 0) {
--
2.4.10