]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: eliminate pointless switch in virFirewallApplyRule
authorLaine Stump <laine@redhat.com>
Tue, 16 Nov 2021 17:19:18 +0000 (12:19 -0500)
committerLaine Stump <laine@redhat.com>
Mon, 13 Dec 2021 18:37:31 +0000 (13:37 -0500)
Since commit b19863640 both useful cases of the switch statement in
this function have made the same call (and the other/default case is
just an error that can never happen). Eliminate the switch to help
eliminate use of currentBackend.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virfirewall.c

index 1a546335f6f573e82b844b3328a70e8fd196bca0..bb14a367d94fe8dc6d3835cbdbfbbf34c0ca5fc4 100644 (file)
@@ -653,31 +653,8 @@ virFirewallApplyRule(virFirewall *firewall,
     if (rule->ignoreErrors)
         ignoreErrors = rule->ignoreErrors;
 
-    switch (currentBackend) {
-    case VIR_FIREWALL_BACKEND_DIRECT:
-        if (virFirewallApplyRuleDirect(rule, ignoreErrors, &output) < 0)
-            return -1;
-        break;
-    case VIR_FIREWALL_BACKEND_FIREWALLD:
-        /* Since we are using raw iptables rules, there is no
-         * advantage to going through firewalld, so instead just add
-         * them directly rather that via dbus calls to firewalld. This
-         * has the useful side effect of eliminating extra unwanted
-         * warning messages in the system logs when trying to delete
-         * rules that don't exist (which is something that happens
-         * often when libvirtd is started, and *always* when firewalld
-         * is restarted)
-         */
-        if (virFirewallApplyRuleDirect(rule, ignoreErrors, &output) < 0)
-            return -1;
-        break;
-
-    case VIR_FIREWALL_BACKEND_AUTOMATIC:
-    case VIR_FIREWALL_BACKEND_LAST:
-    default:
-        virReportEnumRangeError(virFirewallBackend, currentBackend);
+    if (virFirewallApplyRuleDirect(rule, ignoreErrors, &output) < 0)
         return -1;
-    }
 
     if (rule->queryCB && output) {
         if (!(lines = g_strsplit(output, "\n", -1)))