diff mbox series

[v2,08/11] xen/memory: Indent part of acquire_resource()

Message ID 20200922182444.12350-9-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series Multiple fixes to XENMEM_acquire_resource | expand

Commit Message

Andrew Cooper Sept. 22, 2020, 6:24 p.m. UTC
Indent the middle of acquire_resource() inside a do {} while ( 0 ) loop.  This
is broken out specifically to make the following change readable.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: George Dunlap <George.Dunlap@eu.citrix.com>
CC: Ian Jackson <iwj@xenproject.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Wei Liu <wl@xen.org>
CC: Julien Grall <julien@xen.org>
CC: Paul Durrant <paul@xen.org>
CC: Michał Leszczyński <michal.leszczynski@cert.pl>
CC: Hubert Jasudowicz <hubert.jasudowicz@cert.pl>
CC: Tamas K Lengyel <tamas@tklengyel.com>
---
 xen/common/memory.c | 66 +++++++++++++++++++++++++++--------------------------
 1 file changed, 34 insertions(+), 32 deletions(-)

Comments

Durrant, Paul Sept. 24, 2020, 10:36 a.m. UTC | #1
> -----Original Message-----
> From: Andrew Cooper <andrew.cooper3@citrix.com>
> Sent: 22 September 2020 19:25
> To: Xen-devel <xen-devel@lists.xenproject.org>
> Cc: Andrew Cooper <andrew.cooper3@citrix.com>; George Dunlap <George.Dunlap@eu.citrix.com>; Ian
> Jackson <iwj@xenproject.org>; Jan Beulich <JBeulich@suse.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Wei Liu <wl@xen.org>; Julien Grall <julien@xen.org>; Paul Durrant
> <paul@xen.org>; Michał Leszczyński <michal.leszczynski@cert.pl>; Hubert Jasudowicz
> <hubert.jasudowicz@cert.pl>; Tamas K Lengyel <tamas@tklengyel.com>
> Subject: [PATCH v2 08/11] xen/memory: Indent part of acquire_resource()
> 
> Indent the middle of acquire_resource() inside a do {} while ( 0 ) loop.  This
> is broken out specifically to make the following change readable.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Paul Durrant <paul@xen.org>

> ---
> CC: George Dunlap <George.Dunlap@eu.citrix.com>
> CC: Ian Jackson <iwj@xenproject.org>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Wei Liu <wl@xen.org>
> CC: Julien Grall <julien@xen.org>
> CC: Paul Durrant <paul@xen.org>
> CC: Michał Leszczyński <michal.leszczynski@cert.pl>
> CC: Hubert Jasudowicz <hubert.jasudowicz@cert.pl>
> CC: Tamas K Lengyel <tamas@tklengyel.com>
> ---
>  xen/common/memory.c | 66 +++++++++++++++++++++++++++--------------------------
>  1 file changed, 34 insertions(+), 32 deletions(-)
> 
> diff --git a/xen/common/memory.c b/xen/common/memory.c
> index c559935732..369154b7c0 100644
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -1087,44 +1087,46 @@ static int acquire_resource(
>          goto out;
>      }
> 
> -    switch ( xmar.type )
> -    {
> -    case XENMEM_resource_grant_table:
> -        rc = gnttab_acquire_resource(d, xmar.id, xmar.frame, xmar.nr_frames,
> -                                     mfn_list);
> -        break;
> +    do {
> +        switch ( xmar.type )
> +        {
> +        case XENMEM_resource_grant_table:
> +            rc = gnttab_acquire_resource(d, xmar.id, xmar.frame, xmar.nr_frames,
> +                                         mfn_list);
> +            break;
> 
> -    default:
> -        rc = arch_acquire_resource(d, xmar.type, xmar.id, xmar.frame,
> -                                   xmar.nr_frames, mfn_list);
> -        break;
> -    }
> +        default:
> +            rc = arch_acquire_resource(d, xmar.type, xmar.id, xmar.frame,
> +                                       xmar.nr_frames, mfn_list);
> +            break;
> +        }
> 
> -    if ( rc )
> -        goto out;
> +        if ( rc )
> +            goto out;
> 
> -    if ( !paging_mode_translate(currd) )
> -    {
> -        if ( copy_to_guest(xmar.frame_list, mfn_list, xmar.nr_frames) )
> -            rc = -EFAULT;
> -    }
> -    else
> -    {
> -        xen_pfn_t gfn_list[ARRAY_SIZE(mfn_list)];
> -        unsigned int i;
> +        if ( !paging_mode_translate(currd) )
> +        {
> +            if ( copy_to_guest(xmar.frame_list, mfn_list, xmar.nr_frames) )
> +                rc = -EFAULT;
> +        }
> +        else
> +        {
> +            xen_pfn_t gfn_list[ARRAY_SIZE(mfn_list)];
> +            unsigned int i;
> 
> -        if ( copy_from_guest(gfn_list, xmar.frame_list, xmar.nr_frames) )
> -            rc = -EFAULT;
> +            if ( copy_from_guest(gfn_list, xmar.frame_list, xmar.nr_frames) )
> +                rc = -EFAULT;
> 
> -        for ( i = 0; !rc && i < xmar.nr_frames; i++ )
> -        {
> -            rc = set_foreign_p2m_entry(currd, gfn_list[i],
> -                                       _mfn(mfn_list[i]));
> -            /* rc should be -EIO for any iteration other than the first */
> -            if ( rc && i )
> -                rc = -EIO;
> +            for ( i = 0; !rc && i < xmar.nr_frames; i++ )
> +            {
> +                rc = set_foreign_p2m_entry(currd, gfn_list[i],
> +                                           _mfn(mfn_list[i]));
> +                /* rc should be -EIO for any iteration other than the first */
> +                if ( rc && i )
> +                    rc = -EIO;
> +            }
>          }
> -    }
> +    } while ( 0 );
> 
>   out:
>      rcu_unlock_domain(d);
> --
> 2.11.0
diff mbox series

Patch

diff --git a/xen/common/memory.c b/xen/common/memory.c
index c559935732..369154b7c0 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -1087,44 +1087,46 @@  static int acquire_resource(
         goto out;
     }
 
-    switch ( xmar.type )
-    {
-    case XENMEM_resource_grant_table:
-        rc = gnttab_acquire_resource(d, xmar.id, xmar.frame, xmar.nr_frames,
-                                     mfn_list);
-        break;
+    do {
+        switch ( xmar.type )
+        {
+        case XENMEM_resource_grant_table:
+            rc = gnttab_acquire_resource(d, xmar.id, xmar.frame, xmar.nr_frames,
+                                         mfn_list);
+            break;
 
-    default:
-        rc = arch_acquire_resource(d, xmar.type, xmar.id, xmar.frame,
-                                   xmar.nr_frames, mfn_list);
-        break;
-    }
+        default:
+            rc = arch_acquire_resource(d, xmar.type, xmar.id, xmar.frame,
+                                       xmar.nr_frames, mfn_list);
+            break;
+        }
 
-    if ( rc )
-        goto out;
+        if ( rc )
+            goto out;
 
-    if ( !paging_mode_translate(currd) )
-    {
-        if ( copy_to_guest(xmar.frame_list, mfn_list, xmar.nr_frames) )
-            rc = -EFAULT;
-    }
-    else
-    {
-        xen_pfn_t gfn_list[ARRAY_SIZE(mfn_list)];
-        unsigned int i;
+        if ( !paging_mode_translate(currd) )
+        {
+            if ( copy_to_guest(xmar.frame_list, mfn_list, xmar.nr_frames) )
+                rc = -EFAULT;
+        }
+        else
+        {
+            xen_pfn_t gfn_list[ARRAY_SIZE(mfn_list)];
+            unsigned int i;
 
-        if ( copy_from_guest(gfn_list, xmar.frame_list, xmar.nr_frames) )
-            rc = -EFAULT;
+            if ( copy_from_guest(gfn_list, xmar.frame_list, xmar.nr_frames) )
+                rc = -EFAULT;
 
-        for ( i = 0; !rc && i < xmar.nr_frames; i++ )
-        {
-            rc = set_foreign_p2m_entry(currd, gfn_list[i],
-                                       _mfn(mfn_list[i]));
-            /* rc should be -EIO for any iteration other than the first */
-            if ( rc && i )
-                rc = -EIO;
+            for ( i = 0; !rc && i < xmar.nr_frames; i++ )
+            {
+                rc = set_foreign_p2m_entry(currd, gfn_list[i],
+                                           _mfn(mfn_list[i]));
+                /* rc should be -EIO for any iteration other than the first */
+                if ( rc && i )
+                    rc = -EIO;
+            }
         }
-    }
+    } while ( 0 );
 
  out:
     rcu_unlock_domain(d);