From cd23bf182ca752974316ae0697195eddd525f7df Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Sun, 13 Mar 2022 14:21:02 -0400 Subject: [PATCH] util: replace g_snprintf with g_autofreed g_strdup_printf in viriptables.c MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Laine Stump Reviewed-by: Ján Tomko --- src/util/viriptables.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/util/viriptables.c b/src/util/viriptables.c index e9886a200e..6275760de4 100644 --- a/src/util/viriptables.c +++ b/src/util/viriptables.c @@ -163,10 +163,7 @@ iptablesInput(virFirewall *fw, int action, int tcp) { - char portstr[32]; - - g_snprintf(portstr, sizeof(portstr), "%d", port); - portstr[sizeof(portstr) - 1] = '\0'; + g_autofree char *portstr = g_strdup_printf("%d", port); virFirewallAddRule(fw, layer, "--table", "filter", @@ -187,10 +184,7 @@ iptablesOutput(virFirewall *fw, int action, int tcp) { - char portstr[32]; - - g_snprintf(portstr, sizeof(portstr), "%d", port); - portstr[sizeof(portstr) - 1] = '\0'; + g_autofree char *portstr = g_strdup_printf("%d", port); virFirewallAddRule(fw, layer, "--table", "filter", @@ -1028,10 +1022,7 @@ iptablesOutputFixUdpChecksum(virFirewall *fw, int port, int action) { - char portstr[32]; - - g_snprintf(portstr, sizeof(portstr), "%d", port); - portstr[sizeof(portstr) - 1] = '\0'; + g_autofree char *portstr = g_strdup_printf("%d", port); virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4, "--table", "mangle", -- 2.47.2