]> xenbits.xensource.com Git - xen.git/commitdiff
xen/cpupool: Fold error paths in cpupool_create()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 29 Mar 2019 16:51:12 +0000 (16:51 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 7 Jan 2020 12:26:45 +0000 (12:26 +0000)
The compiler can't fold because of the write to *perr in the first hunk.

No functional change, but slightly better compiled code.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
xen/common/cpupool.c

index 4d3adbdd8d4ddc0cced7d70ed813b4e5d61bd7bd..d66b541a9410a033aca648a62f424ac80eae98a7 100644 (file)
@@ -236,10 +236,8 @@ static struct cpupool *cpupool_create(
     {
         if ( (*q)->cpupool_id == poolid )
         {
-            spin_unlock(&cpupool_lock);
-            free_cpupool_struct(c);
             *perr = -EEXIST;
-            return NULL;
+            goto err;
         }
         c->next = *q;
     }
@@ -253,11 +251,7 @@ static struct cpupool *cpupool_create(
     {
         c->sched = scheduler_alloc(sched_id, perr);
         if ( c->sched == NULL )
-        {
-            spin_unlock(&cpupool_lock);
-            free_cpupool_struct(c);
-            return NULL;
-        }
+            goto err;
     }
     c->gran = opt_sched_granularity;
 
@@ -270,6 +264,11 @@ static struct cpupool *cpupool_create(
 
     *perr = 0;
     return c;
+
+ err:
+    spin_unlock(&cpupool_lock);
+    free_cpupool_struct(c);
+    return NULL;
 }
 /*
  * destroys the given cpupool