diff mbox

[1/7] qcow2: Remove unused Error in do_perform_cow()

Message ID 504d7d07c4227d4615b72f46deb34ba77efbea2c.1495536228.git.berto@igalia.com
State New
Headers show

Commit Message

Alberto Garcia May 23, 2017, 11:22 a.m. UTC
qcow2_encrypt_sectors() does not need an Error parameter, and we're
not checking its value anyway, so we can safely remove it.

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 block/qcow2-cluster.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Eric Blake May 23, 2017, 8:21 p.m. UTC | #1
On 05/23/2017 06:22 AM, Alberto Garcia wrote:
> qcow2_encrypt_sectors() does not need an Error parameter, and we're
> not checking its value anyway, so we can safely remove it.

Misleading. You are NOT removing the Error parameter from
qcow2_encrypt_sectors(), but rather are explicitly ignoring any errors
by passing NULL.

I'd update the commit message to something like:

We are relying on the return value of qcow2_encrypt_sectors() to flag
problems, but have no way to report that error to the end user.  Since
we are just throwing away the error, we can pass NULL instead for
simpler code.

A more robust solution would figure out how to pass the original error
(rather than a new message related to our -EIO return) back to the
caller, but that is more invasive.

> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
>  block/qcow2-cluster.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 

With a better commit message,
Reviewed-by: Eric Blake <eblake@redhat.com>
Alberto Garcia May 24, 2017, 9:48 a.m. UTC | #2
On Tue 23 May 2017 10:21:49 PM CEST, Eric Blake wrote:

>> qcow2_encrypt_sectors() does not need an Error parameter, and we're
>> not checking its value anyway, so we can safely remove it.
>
> Misleading. You are NOT removing the Error parameter from
> qcow2_encrypt_sectors(), but rather are explicitly ignoring any errors
> by passing NULL.

Ok, I'll update the comment in the next revision with something like
what you suggest.

Berto
diff mbox

Patch

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 347d94b0d2..3dc170e421 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -440,16 +440,14 @@  static int coroutine_fn do_perform_cow(BlockDriverState *bs,
     }
 
     if (bs->encrypted) {
-        Error *err = NULL;
         int64_t sector = (src_cluster_offset + offset_in_cluster)
                          >> BDRV_SECTOR_BITS;
         assert(s->cipher);
         assert((offset_in_cluster & ~BDRV_SECTOR_MASK) == 0);
         assert((bytes & ~BDRV_SECTOR_MASK) == 0);
         if (qcow2_encrypt_sectors(s, sector, iov.iov_base, iov.iov_base,
-                                  bytes >> BDRV_SECTOR_BITS, true, &err) < 0) {
+                                  bytes >> BDRV_SECTOR_BITS, true, NULL) < 0) {
             ret = -EIO;
-            error_free(err);
             goto out;
         }
     }