xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: julien.grall@arm.com, sstabellini@kernel.org
Subject: [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"
Date: Tue,  6 Dec 2016 19:53:20 +0200	[thread overview]
Message-ID: <1481046800-10809-1-git-send-email-olekstysh@gmail.com> (raw)

From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>

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

Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/irq.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 508028b..6d7e44e 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -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
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

             reply	other threads:[~2016-12-06 17:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 17:53 Oleksandr Tyshchenko [this message]
2016-12-09 16:54 ` [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if" Julien Grall
2016-12-09 19:57   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481046800-10809-1-git-send-email-olekstysh@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).