[libvirt PATCH v2 11/15] nwfilter: transform logic in virNWFilterRuleInstSort to eliminate label

Laine Stump posted 15 patches 4 years, 4 months ago
[libvirt PATCH v2 11/15] nwfilter: transform logic in virNWFilterRuleInstSort to eliminate label
Posted by Laine Stump 4 years, 4 months ago
This rewrite of a nested conditional produces the same results, but
eliminate a goto and corresponding label.

Signed-off-by: Laine Stump <laine@redhat.com>
---
 src/nwfilter/nwfilter_ebiptables_driver.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c
index cc0f3f93d9..94eaac927a 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -3113,13 +3113,12 @@ virNWFilterRuleInstSort(const void *a, const void *b)
     /* ensure root chain commands appear before all others since
        we will need them to create the child chains */
     if (root_a) {
-        if (root_b)
-            goto normal;
-        return -1; /* a before b */
-    }
-    if (root_b)
+        if (!root_b)
+            return -1; /* a before b */
+    } else if (root_b) {
         return 1; /* b before a */
- normal:
+    }
+
     /* priorities are limited to range [-1000, 1000] */
     return insta->priority - instb->priority;
 }
-- 
2.25.4

Re: [libvirt PATCH v2 11/15] nwfilter: transform logic in virNWFilterRuleInstSort to eliminate label
Posted by Ján Tomko 4 years, 4 months ago
On a Tuesday in 2020, Laine Stump wrote:
>This rewrite of a nested conditional produces the same results, but
>eliminate a goto and corresponding label.
>
>Signed-off-by: Laine Stump <laine@redhat.com>
>---
> src/nwfilter/nwfilter_ebiptables_driver.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano