From 5f0f8f6c5d2f93b2097c6aede834eec01ebcdaad Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Thu, 2 Jul 2020 22:39:38 -0400 Subject: [PATCH] nwfilter: use g_auto() for all virBuffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laine Stump Reviewed-by: Ján Tomko --- src/nwfilter/nwfilter_ebiptables_driver.c | 8 +++----- src/nwfilter/nwfilter_gentech_driver.c | 6 ++---- src/nwfilter/nwfilter_learnipaddr.c | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index 6fc8044c8d..dad631f03b 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -190,7 +190,7 @@ _printDataType(virNWFilterVarCombIterPtr vars, bool done; char *data; uint8_t ctr; - virBuffer vb = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) vb = VIR_BUFFER_INITIALIZER; char *flags; if (printVar(vars, buf, bufsize, item, &done) < 0) @@ -1528,7 +1528,7 @@ _iptablesCreateRuleInstance(virFirewallPtr fw, static int printStateMatchFlags(int32_t flags, char **bufptr) { - virBuffer buf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virNWFilterPrintStateMatchFlags(&buf, "", flags, @@ -1798,7 +1798,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, bool hasMask = false; virFirewallRulePtr fwrule; int ret = -1; - virBuffer buf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; if (STREQ(chainSuffix, virNWFilterChainSuffixTypeToString( @@ -2423,8 +2423,6 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, ret = 0; cleanup: - virBufferFreeAndReset(&buf); - return ret; } diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 6789a4a3fa..b7633eb10a 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -426,15 +426,13 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter, if (!virNWFilterVarAccessIsAvailable(rule->varAccess[j], vars)) { char *varAccess; - virBuffer buf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; virNWFilterVarAccessPrint(rule->varAccess[j], &buf); val = virNWFilterVarValueCreateSimpleCopyValue("1"); - if (!val) { - virBufferFreeAndReset(&buf); + if (!val) return -1; - } varAccess = virBufferContentAndReset(&buf); rc = virHashUpdateEntry(missing_vars, varAccess, val); diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 4ce8d5ba03..14c66cff35 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -397,7 +397,7 @@ learnIPAddressThread(void *arg) req->binding->portdevname); int dhcp_opts_len; char macaddr[VIR_MAC_STRING_BUFLEN]; - virBuffer buf = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; char *filter = NULL; uint16_t etherType; bool showError = true;