Skip to contentSkip to conversation

xen/cpupool: Fold error paths in cpupool_create()

PATCH In review Andrew Cooper 2 participants 2 messages Jan 6, 2020 – Jan 7, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/cpupool: Fold error paths in cpupool_create()

The compiler can't fold because of the write to *perr in the first hunk.

No functional change, but slightly better compiled code.

---
CC: Juergen Gross <[email protected]>
CC: Dario Faggioli <[email protected]>

---
 xen/common/cpupool.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
xen/common/cpupool.c +7 -8
index 4d3adbdd8d..d66b541a94 100644
@@ -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
Signature · 7 lines
2.11.0


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