Skip to contentSkip to conversation

arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"

PATCH In review Oleksandr Tyshchenko 3 participants 3 messages Dec 6, 2016 – Dec 9, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"

From: Oleksandr Tyshchenko <[email protected]>

Remove one layer of "if" by reordering the check in route_irq_to_guest() to make code more clearer.

---
 xen/arch/arm/irq.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
xen/arch/arm/irq.c +7 -11
index 508028b..6d7e44e 100644
@@ -481,21 +481,17 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
         {
             struct domain *ad = irq_get_domain(desc);
 
-            if ( d == ad )
-            {
-                if ( irq_get_guest_info(desc)->virq != virq )
-                {
-                    printk(XENLOG_G_ERR
-                           "d%u: IRQ %u is already assigned to vIRQ %u\n",
-                           d->domain_id, irq, irq_get_guest_info(desc)->virq);
-                    retval = -EBUSY;
-                }
-            }
-            else
+            if ( d != ad )
             {
                 printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
                        irq, ad->domain_id);
                 retval = -EBUSY;
+            } else if ( irq_get_guest_info(desc)->virq != virq )
+            {
+                printk(XENLOG_G_ERR
+                       "d%u: IRQ %u is already assigned to vIRQ %u\n",
+                       d->domain_id, irq, irq_get_guest_info(desc)->virq);
+                retval = -EBUSY;
             }
         }
         else
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Reviewed-by on v1 1/1
#1 lore raw

Hi Oleksandr,

Thank you for the patch.

Quoted 26 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Remove one layer of "if" by reordering the check in route_irq_to_guest() to make code more clearer.

---
 xen/arch/arm/irq.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
xen/arch/arm/irq.c +0 -7
index 508028b..6d7e44e 100644
@@ -481,21 +481,17 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
         {
             struct domain *ad = irq_get_domain(desc);
 
-            if ( d == ad )
-            {
-                if ( irq_get_guest_info(desc)->virq != virq )
-                {
-                    printk(XENLOG_G_ERR
-                           "d%u: IRQ %u is already assigned to vIRQ %u\n",
-                           d->domain_id, irq, irq_get_guest_info(desc)->virq);

xen/arch/arm/irq.c int route_irq_to_guest(struct domain *d, unsigned int virq, · line 489

Quoted 10 lines
xen/arch/arm/irq.c +2 -4
-                    retval = -EBUSY;
-                }
-            }
-            else
+            if ( d != ad )
             {
                 printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
                        irq, ad->domain_id);
                 retval = -EBUSY;
+            } else if ( irq_get_guest_info(desc)->virq != virq )

In Xen coding style the } and else if should be in separate line. E.g

}
else if ( ... )

With that fixed:

Stefano, would you be happy to fix this minor coding style issue while committing?

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw
Quoted 50 lines · Julien Grall

Hi Oleksandr,

Thank you for the patch.

Quoted 29 lines · Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

Remove one layer of "if" by reordering the check in route_irq_to_guest() to make code more clearer.

---
 xen/arch/arm/irq.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)
xen/arch/arm/irq.c +0 -8
index 508028b..6d7e44e 100644
@@ -481,21 +481,17 @@ int route_irq_to_guest(struct domain *d, unsigned int
 virq,
         {
             struct domain *ad = irq_get_domain(desc);
 
-            if ( d == ad )
-            {
-                if ( irq_get_guest_info(desc)->virq != virq )
-                {
-                    printk(XENLOG_G_ERR
-                           "d%u: IRQ %u is already assigned to vIRQ %u\n",
-                           d->domain_id, irq,
 irq_get_guest_info(desc)->virq);
-                    retval = -EBUSY;

xen/arch/arm/irq.c int route_irq_to_guest(struct domain *d, unsigned int · line 492

Quoted 10 lines
xen/arch/arm/irq.c +2 -3
-                }
-            }
-            else
+            if ( d != ad )
             {
                 printk(XENLOG_G_ERR "IRQ %u is already used by domain
 %u\n",
                        irq, ad->domain_id);
                 retval = -EBUSY;
+            } else if ( irq_get_guest_info(desc)->virq != virq )

In Xen coding style the } and else if should be in separate line. E.g

}
else if ( ... )

Quoted 6 lines

With that fixed:

Stefano, would you be happy to fix this minor coding style issue while committing?

done

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel