diff mbox

[v20,12/30] block: refactor bdrv_reopen_commit

Message ID 20170602112158.232757-13-vsementsov@virtuozzo.com
State New
Headers show

Commit Message

Vladimir Sementsov-Ogievskiy June 2, 2017, 11:21 a.m. UTC
Add bs local variable to simplify code.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

John Snow June 2, 2017, 9:57 p.m. UTC | #1
On 06/02/2017 07:21 AM, Vladimir Sementsov-Ogievskiy wrote:
> Add bs local variable to simplify code.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>  block.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 50ba264143..04af7697dc 100644
> --- a/block.c
> +++ b/block.c
> @@ -2945,9 +2945,11 @@ error:
>  void bdrv_reopen_commit(BDRVReopenState *reopen_state)
>  {
>      BlockDriver *drv;
> +    BlockDriverState *bs;
>  
>      assert(reopen_state != NULL);
> -    drv = reopen_state->bs->drv;
> +    bs = reopen_state->bs;
> +    drv = bs->drv;
>      assert(drv != NULL);
>  
>      /* If there are any driver level actions to take */
> @@ -2956,13 +2958,13 @@ void bdrv_reopen_commit(BDRVReopenState *reopen_state)
>      }
>  
>      /* set BDS specific flags now */
> -    QDECREF(reopen_state->bs->explicit_options);
> +    QDECREF(bs->explicit_options);
>  
> -    reopen_state->bs->explicit_options   = reopen_state->explicit_options;
> -    reopen_state->bs->open_flags         = reopen_state->flags;
> -    reopen_state->bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
> +    bs->explicit_options   = reopen_state->explicit_options;
> +    bs->open_flags         = reopen_state->flags;
> +    bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
>  
> -    bdrv_refresh_limits(reopen_state->bs, NULL);
> +    bdrv_refresh_limits(bs, NULL);
>  }
>  
>  /*
> 

It's not immediately obvious that this is safe (can reopen_commit change
reopen_state->bs ?) -- but it doesn't, so:

Reviewed-by: John Snow <jsnow@redhat.com>
diff mbox

Patch

diff --git a/block.c b/block.c
index 50ba264143..04af7697dc 100644
--- a/block.c
+++ b/block.c
@@ -2945,9 +2945,11 @@  error:
 void bdrv_reopen_commit(BDRVReopenState *reopen_state)
 {
     BlockDriver *drv;
+    BlockDriverState *bs;
 
     assert(reopen_state != NULL);
-    drv = reopen_state->bs->drv;
+    bs = reopen_state->bs;
+    drv = bs->drv;
     assert(drv != NULL);
 
     /* If there are any driver level actions to take */
@@ -2956,13 +2958,13 @@  void bdrv_reopen_commit(BDRVReopenState *reopen_state)
     }
 
     /* set BDS specific flags now */
-    QDECREF(reopen_state->bs->explicit_options);
+    QDECREF(bs->explicit_options);
 
-    reopen_state->bs->explicit_options   = reopen_state->explicit_options;
-    reopen_state->bs->open_flags         = reopen_state->flags;
-    reopen_state->bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
+    bs->explicit_options   = reopen_state->explicit_options;
+    bs->open_flags         = reopen_state->flags;
+    bs->read_only = !(reopen_state->flags & BDRV_O_RDWR);
 
-    bdrv_refresh_limits(reopen_state->bs, NULL);
+    bdrv_refresh_limits(bs, NULL);
 }
 
 /*