[PATCH] block/qcow2-cluster: remove dead code

Elena Afanasova posted 1 patch 3 years, 7 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/e04b538ddbf6b6612c0c94602740ff78a98812d7.camel@gmail.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
block/qcow2-cluster.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] block/qcow2-cluster: remove dead code
Posted by Elena Afanasova 3 years, 7 months ago
Since handle_dependencies() returns 0 or -EAGAIN the following case can be removed.
Spotted by PVS-Studio.

Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
---
 block/qcow2-cluster.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index aa87d3e99b..e2e0db0cc9 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -1806,8 +1806,6 @@ again:
              * structs before starting over. */
             assert(*m == NULL);
             goto again;
-        } else if (ret < 0) {
-            return ret;
         } else if (cur_bytes == 0) {
             break;
         } else {
-- 
2.25.1



Re: [PATCH] block/qcow2-cluster: remove dead code
Posted by Kevin Wolf 3 years, 7 months ago
Am 15.10.2020 um 14:13 hat Elena Afanasova geschrieben:
> Since handle_dependencies() returns 0 or -EAGAIN the following case can be removed.
> Spotted by PVS-Studio.
> 
> Signed-off-by: Elena Afanasova <eafanasova@gmail.com>
> ---
>  block/qcow2-cluster.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index aa87d3e99b..e2e0db0cc9 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -1806,8 +1806,6 @@ again:
>               * structs before starting over. */
>              assert(*m == NULL);
>              goto again;
> -        } else if (ret < 0) {
> -            return ret;
>          } else if (cur_bytes == 0) {
>              break;
>          } else {

Technically correct, but let's keep it for anyone who will return a
different error code in the future. I think we should always check for
any error even if it is currently not produced.

Kevin