WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 1/3] xen: Control-flow cleanup

To: Bastian Blank <waldi@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 1/3] xen: Control-flow cleanup
From: Jeremy Fitzhardinge <jeremy@xxxxxxxx>
Date: Wed, 24 Mar 2010 10:53:13 -0700
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Wed, 24 Mar 2010 10:54:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20100324115137.GA10770@xxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20100324115137.GA10770@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Lightning/1.0b2pre Thunderbird/3.0.3
On 03/24/2010 04:51 AM, Bastian Blank wrote:
It is nice to have only one return, but it does not make it easier to
read or change.

Thanks, I agree, but I tweaked it to use "goto out" to preserve the single return, and fixed some lines which can now be unwrapped with the shallower indent.

    J

Signed-off-by: Bastian Blank<waldi@xxxxxxxxxx>
---
  arch/x86/xen/pci.c |   52 +++++++++++++++++++++++++++-------------------------
  1 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/arch/x86/xen/pci.c b/arch/x86/xen/pci.c
index 61e1ade..a83c74c 100644
--- a/arch/x86/xen/pci.c
+++ b/arch/x86/xen/pci.c
@@ -42,32 +42,34 @@ int xen_register_gsi(u32 gsi, int triggering, int polarity)

        printk(KERN_DEBUG "xen: -->  irq=%d\n", irq);

-       if (irq>= 0) {
-               setup_gsi.gsi = gsi;
-               setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ?
-                               0 : 1);
-               setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
-
-               rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi,&setup_gsi);
-               if (rc == -EEXIST)
-                       printk(KERN_INFO "Already setup the GSI :%d\n", gsi);
-               else if (rc) {
-                       printk(KERN_ERR "Failed to setup GSI :%d, 
err_code:%d\n",
-                                       gsi, rc);
-                       BUG();
-               }
+       if (irq<  0)
+               return irq;
+
+       setup_gsi.gsi = gsi;
+       setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ?
+                       0 : 1);
+       setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
+
+       rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi,&setup_gsi);
+       if (rc == -EEXIST)
+               printk(KERN_INFO "Already setup the GSI :%d\n", gsi);
+       else if (rc) {
+               printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n",
+                               gsi, rc);
+               BUG();
+       }

-               map_irq.domid = DOMID_SELF;
-               map_irq.type = MAP_PIRQ_TYPE_GSI;
-               map_irq.index = gsi;
-               map_irq.pirq = irq;
+       map_irq.domid = DOMID_SELF;
+       map_irq.type = MAP_PIRQ_TYPE_GSI;
+       map_irq.index = gsi;
+       map_irq.pirq = irq;

-               rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq,&map_irq);
-               if (rc) {
-                       printk(KERN_WARNING "xen map irq failed %d\n", rc);
-                       irq = -1;
-               }
+       rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq,&map_irq);
+       if (rc) {
+               printk(KERN_WARNING "xen map irq failed %d\n", rc);
+               return -1;
        }
+
        return irq;
  }



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>