The type of interface to attach is held in the variable 'typ'. Depending on interface type selected by user, the variable is set either to 1 (network), or 2 (bridge). Lets use an enum instead. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- tools/virsh-domain.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bab44fe..b465eb5 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -854,6 +854,11 @@ static int parseRateStr(const char *rateStr, virNetDevBandwidthRatePtr rate) return 0; } +typedef enum { + IFACE_TYPE_NETWORK, + IFACE_TYPE_BRIDGE, +} vshCmdAttachInterfaceType; + static bool cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) { @@ -862,7 +867,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) *type = NULL, *source = NULL, *model = NULL, *inboundStr = NULL, *outboundStr = NULL; virNetDevBandwidthRate inbound, outbound; - int typ; + vshCmdAttachInterfaceType typ; int ret; bool functionReturn = false; virBuffer buf = VIR_BUFFER_INITIALIZER; @@ -902,9 +907,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) /* check interface type */ if (STREQ(type, "network")) { - typ = 1; + typ = IFACE_TYPE_NETWORK; } else if (STREQ(type, "bridge")) { - typ = 2; + typ = IFACE_TYPE_BRIDGE; } else { vshError(ctl, _("No support for %s in command 'attach-interface'"), type); @@ -938,9 +943,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virBufferAsprintf(&buf, "<interface type='%s'>\n", type); virBufferAdjustIndent(&buf, 2); - if (typ == 1) + if (typ == IFACE_TYPE_NETWORK) virBufferAsprintf(&buf, "<source network='%s'/>\n", source); - else if (typ == 2) + else if (typ == IFACE_TYPE_BRIDGE) virBufferAsprintf(&buf, "<source bridge='%s'/>\n", source); if (target != NULL) -- 2.0.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list