99 lines
3.3 KiB
Diff
99 lines
3.3 KiB
Diff
From ca441a9e1e6d757cd1aa7dfb84c0e37cb1924b87 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <ca441a9e1e6d757cd1aa7dfb84c0e37cb1924b87@dist-git>
|
|
From: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
|
|
Date: Tue, 30 Jul 2019 15:30:47 +0200
|
|
Subject: [PATCH] util: netdevopenvswitch: use VIR_AUTOFREE instead of VIR_FREE
|
|
for scalar types
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
By making use of GNU C's cleanup attribute handled by the
|
|
VIR_AUTOFREE macro for declaring scalar variables, majority
|
|
of the VIR_FREE calls can be dropped, which in turn leads to
|
|
getting rid of most of our cleanup sections.
|
|
|
|
Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
|
|
Reviewed-by: Erik Skultety <eskultet@redhat.com>
|
|
(cherry picked from commit 2d9be4d8b4cfea2a85a8ebe21ffadf4b3101a09b)
|
|
|
|
Prerequisite of: https://bugzilla.redhat.com/show_bug.cgi?id=1721434
|
|
|
|
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
Message-Id: <56656242ad6da70744bfda6d0757125eea669751.1564493409.git.mprivozn@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/util/virnetdevopenvswitch.c | 18 ++++++------------
|
|
1 file changed, 6 insertions(+), 12 deletions(-)
|
|
|
|
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
|
|
index f86f698430..36c587efdb 100644
|
|
--- a/src/util/virnetdevopenvswitch.c
|
|
+++ b/src/util/virnetdevopenvswitch.c
|
|
@@ -149,10 +149,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
|
|
char macaddrstr[VIR_MAC_STRING_BUFLEN];
|
|
char ifuuidstr[VIR_UUID_STRING_BUFLEN];
|
|
char vmuuidstr[VIR_UUID_STRING_BUFLEN];
|
|
- char *attachedmac_ex_id = NULL;
|
|
- char *ifaceid_ex_id = NULL;
|
|
- char *profile_ex_id = NULL;
|
|
- char *vmid_ex_id = NULL;
|
|
+ VIR_AUTOFREE(char *) attachedmac_ex_id = NULL;
|
|
+ VIR_AUTOFREE(char *) ifaceid_ex_id = NULL;
|
|
+ VIR_AUTOFREE(char *) profile_ex_id = NULL;
|
|
+ VIR_AUTOFREE(char *) vmid_ex_id = NULL;
|
|
|
|
virMacAddrFormat(macaddr, macaddrstr);
|
|
virUUIDFormat(ovsport->interfaceID, ifuuidstr);
|
|
@@ -209,10 +209,6 @@ int virNetDevOpenvswitchAddPort(const char *brname, const char *ifname,
|
|
|
|
ret = 0;
|
|
cleanup:
|
|
- VIR_FREE(attachedmac_ex_id);
|
|
- VIR_FREE(ifaceid_ex_id);
|
|
- VIR_FREE(vmid_ex_id);
|
|
- VIR_FREE(profile_ex_id);
|
|
virCommandFree(cmd);
|
|
return ret;
|
|
}
|
|
@@ -339,10 +335,10 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
|
|
virDomainInterfaceStatsPtr stats)
|
|
{
|
|
virCommandPtr cmd = NULL;
|
|
- char *output;
|
|
char *tmp;
|
|
bool gotStats = false;
|
|
int ret = -1;
|
|
+ VIR_AUTOFREE(char *) output = NULL;
|
|
|
|
/* Just ensure the interface exists in ovs */
|
|
cmd = virCommandNew(OVSVSCTL);
|
|
@@ -399,7 +395,6 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname,
|
|
ret = 0;
|
|
|
|
cleanup:
|
|
- VIR_FREE(output);
|
|
virCommandFree(cmd);
|
|
return ret;
|
|
}
|
|
@@ -425,7 +420,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
|
|
size_t ntokens = 0;
|
|
int status;
|
|
int ret = -1;
|
|
- char *ovs_timeout = NULL;
|
|
+ VIR_AUTOFREE(char *) ovs_timeout = NULL;
|
|
|
|
/* Openvswitch vhostuser path are hardcoded to
|
|
* /<runstatedir>/openvswitch/<ifname>
|
|
@@ -457,7 +452,6 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
|
|
cleanup:
|
|
virStringListFreeCount(tokens, ntokens);
|
|
virCommandFree(cmd);
|
|
- VIR_FREE(ovs_timeout);
|
|
return ret;
|
|
}
|
|
|
|
--
|
|
2.22.0
|
|
|