]> git.proxmox.com Git - pve-manager.git/commitdiff
api2: network: improve code readability
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 7 Jun 2023 09:49:07 +0000 (11:49 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 7 Jun 2023 15:04:29 +0000 (17:04 +0200)
nested conditionals stretching over multiple lines are always a bit hard to
untangle, so let's make it explicit:

1. is the interface a bridge
2. if it is, are we looking for one?
3. is it something else that we are looking for?

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
PVE/API2/Network.pm

index 558d78a994e16b27f9386fd13a96aa1eed770f42..00d964a79fa834a3cd41ccf7013d4224443f7597 100644 (file)
@@ -247,9 +247,9 @@ __PACKAGE__->register_method({
 
            for my $k (sort keys $ifaces->%*) {
                my $type = $ifaces->{$k}->{type};
-               my $match = ($tfilter eq $type) || (
-                   ($tfilter =~ /^any(_local)?_bridge$/) &&
-                   ($type eq 'bridge' || $type eq 'OVSBridge'));
+               my $is_bridge = $type eq 'bridge' || $type eq 'OVSBridge';
+               my $bridge_match = $is_bridge && $tfilter =~ /^any(_local)?_bridge$/;
+               my $match = $tfilter eq $type || $bridge_match;
                delete $ifaces->{$k} if !$match;
            }