Patchwork [3/5] qemu-img: avoid excessive BlockFragInfo line length

login
register
mail settings
Submitter Stefan Hajnoczi
Date Feb. 5, 2013, 6:54 p.m.
Message ID <1360090451-26543-4-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/218321/
State New
Headers show

Comments

Stefan Hajnoczi - Feb. 5, 2013, 6:54 p.m.
The qemu-img check printf() statement that shows BlockFragInfo results
is poorly formatted.  Introduce a local variable to shorten the lines
and restore proper indentation.

The next patch adds a field to BlockFragInfo so it is beneficial to
straighten out this code before modifying it.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 qemu-img.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
Eric Blake - Feb. 5, 2013, 10:14 p.m.
On 02/05/2013 11:54 AM, Stefan Hajnoczi wrote:
> The qemu-img check printf() statement that shows BlockFragInfo results
> is poorly formatted.  Introduce a local variable to shorten the lines
> and restore proper indentation.
> 
> The next patch adds a field to BlockFragInfo so it is beneficial to
> straighten out this code before modifying it.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  qemu-img.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

Patch

diff --git a/qemu-img.c b/qemu-img.c
index 85d3740..167d65f 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -389,6 +389,7 @@  static int img_check(int argc, char **argv)
     const char *filename, *fmt;
     BlockDriverState *bs;
     BdrvCheckResult result;
+    BlockFragInfo *bfi = &result.bfi;
     int fix = 0;
     int flags = BDRV_O_FLAGS | BDRV_O_CHECK;
 
@@ -468,11 +469,12 @@  static int img_check(int argc, char **argv)
         }
     }
 
-    if (result.bfi.total_clusters != 0 && result.bfi.allocated_clusters != 0) {
-        printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, %0.2f%% fragmented\n",
-        result.bfi.allocated_clusters, result.bfi.total_clusters,
-        result.bfi.allocated_clusters * 100.0 / result.bfi.total_clusters,
-        result.bfi.fragmented_clusters * 100.0 / result.bfi.allocated_clusters);
+    if (bfi->total_clusters != 0 && bfi->allocated_clusters != 0) {
+        printf("%" PRId64 "/%" PRId64 "= %0.2f%% allocated, "
+               "%0.2f%% fragmented\n",
+               bfi->allocated_clusters, bfi->total_clusters,
+               bfi->allocated_clusters * 100.0 / bfi->total_clusters,
+               bfi->fragmented_clusters * 100.0 / bfi->allocated_clusters);
     }
 
     bdrv_delete(bs);