]> Git Repo - qemu.git/commitdiff
qcow2: Emit errp when truncating the image tail
authorMax Reitz <[email protected]>
Mon, 9 Oct 2017 15:54:31 +0000 (17:54 +0200)
committerMax Reitz <[email protected]>
Thu, 26 Oct 2017 13:01:14 +0000 (15:01 +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 <[email protected]>
Message-id: 20171009155431[email protected]
Reviewed-by: Pavel Butsykin <[email protected]>
Reviewed-by: Jeff Cody <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
block/qcow2.c

index f77b490cc68f7eda20b6b43ed1a311284058f549..d3e114bce56fdeeb2fce70e4c6d7bcb78d65ddd3 100644 (file)
@@ -3145,12 +3145,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 {
This page took 0.031187 seconds and 4 git commands to generate.