]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: replace g_snprintf with g_autofreed g_strdup_printf in viriptables.c
authorLaine Stump <laine@redhat.com>
Sun, 13 Mar 2022 18:21:02 +0000 (14:21 -0400)
committerLaine Stump <laine@redhat.com>
Wed, 24 Aug 2022 16:22:47 +0000 (12:22 -0400)
Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/util/viriptables.c

index e9886a200edd5ee553a94d7d292e68dd0d33c6dc..6275760de4de1fc16ae1d5f1d4fa8ba33575b394 100644 (file)
@@ -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",