[Qemu-devel] [PATCH 2/3] block/stream: refactor stream_run: drop goto

Andrey Shinkevich posted 3 patches 6 years, 10 months ago
Maintainers: John Snow <jsnow@redhat.com>, Max Reitz <mreitz@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>, Markus Armbruster <armbru@redhat.com>
There is a newer version of this series
[Qemu-devel] [PATCH 2/3] block/stream: refactor stream_run: drop goto
Posted by Andrey Shinkevich 6 years, 10 months ago
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
---
 block/stream.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/block/stream.c b/block/stream.c
index 6253c86..c065e99 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -122,13 +122,12 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
     void *buf;
 
     if (!bs->backing) {
-        goto out;
+        return 0;
     }
 
     len = bdrv_getlength(bs);
     if (len < 0) {
-        ret = len;
-        goto out;
+        return len;
     }
     job_progress_set_remaining(&s->common.job, len);
 
@@ -205,14 +204,10 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
         bdrv_disable_copy_on_read(bs);
     }
 
-    /* Do not remove the backing file if an error was there but ignored.  */
-    ret = error;
-
     qemu_vfree(buf);
 
-out:
-    /* Modify backing chain and close BDSes in main loop */
-    return ret;
+    /* Do not remove the backing file if an error was there but ignored. */
+    return error;
 }
 
 static const BlockJobDriver stream_job_driver = {
-- 
1.8.3.1

Re: [Qemu-devel] [PATCH 2/3] block/stream: refactor stream_run: drop goto
Posted by Vladimir Sementsov-Ogievskiy 6 years, 10 months ago
missed
From:

29.03.2019 16:29, Andrey Shinkevich wrote:
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
> ---
>   block/stream.c | 13 ++++---------
>   1 file changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/block/stream.c b/block/stream.c
> index 6253c86..c065e99 100644
> --- a/block/stream.c
> +++ b/block/stream.c
> @@ -122,13 +122,12 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
>       void *buf;
>   
>       if (!bs->backing) {
> -        goto out;
> +        return 0;
>       }
>   
>       len = bdrv_getlength(bs);
>       if (len < 0) {
> -        ret = len;
> -        goto out;
> +        return len;
>       }
>       job_progress_set_remaining(&s->common.job, len);
>   
> @@ -205,14 +204,10 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
>           bdrv_disable_copy_on_read(bs);
>       }
>   
> -    /* Do not remove the backing file if an error was there but ignored.  */
> -    ret = error;
> -
>       qemu_vfree(buf);
>   
> -out:
> -    /* Modify backing chain and close BDSes in main loop */
> -    return ret;
> +    /* Do not remove the backing file if an error was there but ignored. */
> +    return error;
>   }
>   
>   static const BlockJobDriver stream_job_driver = {
> 


-- 
Best regards,
Vladimir