* [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"
@ 2016-12-06 17:53 Oleksandr Tyshchenko
2016-12-09 16:54 ` Julien Grall
0 siblings, 1 reply; 3+ messages in thread
From: Oleksandr Tyshchenko @ 2016-12-06 17:53 UTC (permalink / raw)
To: xen-devel; +Cc: julien.grall, sstabellini
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"
2016-12-06 17:53 [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if" Oleksandr Tyshchenko
@ 2016-12-09 16:54 ` Julien Grall
2016-12-09 19:57 ` Stefano Stabellini
0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2016-12-09 16:54 UTC (permalink / raw)
To: Oleksandr Tyshchenko, xen-devel; +Cc: sstabellini
Hi Oleksandr,
Thank you for the patch.
On 06/12/16 17:53, Oleksandr Tyshchenko wrote:
> 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 )
In Xen coding style the } and else if should be in separate line. E.g
}
else if ( ... )
With that fixed:
Reviewed-by: Julien Grall <julien.grall@arm.com>
Stefano, would you be happy to fix this minor coding style issue while
committing?
Cheers,
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if"
2016-12-09 16:54 ` Julien Grall
@ 2016-12-09 19:57 ` Stefano Stabellini
0 siblings, 0 replies; 3+ messages in thread
From: Stefano Stabellini @ 2016-12-09 19:57 UTC (permalink / raw)
To: Julien Grall; +Cc: Oleksandr Tyshchenko, xen-devel, sstabellini
On Fri, 9 Dec 2016, Julien Grall wrote:
> Hi Oleksandr,
>
> Thank you for the patch.
>
> On 06/12/16 17:53, Oleksandr Tyshchenko wrote:
> > 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 )
>
> In Xen coding style the } and else if should be in separate line. E.g
>
> }
> else if ( ... )
>
> With that fixed:
>
> Reviewed-by: Julien Grall <julien.grall@arm.com>
>
> Stefano, would you be happy to fix this minor coding style issue while
> committing?
done
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-12-09 19:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-06 17:53 [PATCH v1] arm/irq: Reorder check in route_irq_to_guest() to avoid 4 layers of "if" Oleksandr Tyshchenko
2016-12-09 16:54 ` Julien Grall
2016-12-09 19:57 ` Stefano Stabellini
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).