qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-block] [PATCH] qcow2: Emit errp when truncating the image tail


From: Max Reitz
Subject: [Qemu-block] [PATCH] qcow2: Emit errp when truncating the image tail
Date: Mon, 9 Oct 2017 17:54:31 +0200

bdrv_truncate() has an errp parameter which is always set when an error
occurs.  Let's use that instead of a plain strerror().

Signed-off-by: Max Reitz <address@hidden>
---
 block/qcow2.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index dff903e05c..2f6a8e1ff8 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3150,12 +3150,13 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t 
offset,
             return last_cluster;
         }
         if ((last_cluster + 1) * s->cluster_size < old_file_size) {
-            ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
-                                PREALLOC_MODE_OFF, NULL);
-            if (ret < 0) {
-                warn_report("Failed to truncate the tail of the image: %s",
-                            strerror(-ret));
-                ret = 0;
+            Error *local_err = NULL;
+
+            bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
+                          PREALLOC_MODE_OFF, &local_err);
+            if (local_err) {
+                warn_reportf_err(local_err,
+                                 "Failed to truncate the tail of the image: ");
             }
         }
     } else {
-- 
2.13.6




reply via email to

[Prev in Thread] Current Thread [Next in Thread]