From patchwork Mon Dec 6 14:25:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 74370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B2B80B70AF for ; Tue, 7 Dec 2010 01:41:31 +1100 (EST) Received: from localhost ([127.0.0.1]:55770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPcFs-0001ru-Sx for incoming@patchwork.ozlabs.org; Mon, 06 Dec 2010 09:41:28 -0500 Received: from [140.186.70.92] (port=38771 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPc0o-00030s-As for qemu-devel@nongnu.org; Mon, 06 Dec 2010 09:25:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPc0m-0000Lj-HC for qemu-devel@nongnu.org; Mon, 06 Dec 2010 09:25:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPc0m-0000LV-7F for qemu-devel@nongnu.org; Mon, 06 Dec 2010 09:25:52 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB6EPovK004270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 6 Dec 2010 09:25:50 -0500 Received: from red-feather.redhat.com (ovpn-113-53.phx2.redhat.com [10.3.113.53]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oB6EPfka018335; Mon, 6 Dec 2010 09:25:49 -0500 From: Jes.Sorensen@redhat.com To: kwolf@redhat.com Date: Mon, 6 Dec 2010 15:25:39 +0100 Message-Id: <1291645540-9784-7-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1291645540-9784-1-git-send-email-Jes.Sorensen@redhat.com> References: <1291645540-9784-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 6/7] Fix formatting and missing braces in qemu-img.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Signed-off-by: Jes Sorensen Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefan Hajnoczi --- qemu-img.c | 77 +++++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 51 insertions(+), 26 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index c7d0ca8..d812db0 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -305,8 +305,9 @@ static int img_create(int argc, char **argv) flags = 0; for(;;) { c = getopt(argc, argv, "F:b:f:he6o:"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -333,8 +334,9 @@ static int img_create(int argc, char **argv) } /* Get the filename */ - if (optind >= argc) + if (optind >= argc) { help(); + } filename = argv[optind++]; if (options && !strcmp(options, "?")) { @@ -473,8 +475,9 @@ static int img_check(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -484,8 +487,9 @@ static int img_check(int argc, char **argv) break; } } - if (optind >= argc) + if (optind >= argc) { help(); + } filename = argv[optind++]; bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS); @@ -549,8 +553,9 @@ static int img_commit(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -560,8 +565,9 @@ static int img_commit(int argc, char **argv) break; } } - if (optind >= argc) + if (optind >= argc) { help(); + } filename = argv[optind++]; bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_RDWR); @@ -685,8 +691,9 @@ static int img_convert(int argc, char **argv) flags = 0; for(;;) { c = getopt(argc, argv, "f:O:B:s:hce6o:"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -719,7 +726,9 @@ static int img_convert(int argc, char **argv) } bs_n = argc - optind - 1; - if (bs_n < 1) help(); + if (bs_n < 1) { + help(); + } out_filename = argv[argc - 1]; @@ -907,8 +916,9 @@ static int img_convert(int argc, char **argv) } assert (remainder == 0); - if (n < cluster_sectors) + if (n < cluster_sectors) { memset(buf + n * 512, 0, cluster_size - n * 512); + } if (is_not_zero(buf, cluster_size)) { ret = bdrv_write_compressed(out_bs, sector_num, buf, cluster_sectors); @@ -928,12 +938,14 @@ static int img_convert(int argc, char **argv) sector_num = 0; // total number of sectors converted so far for(;;) { nb_sectors = total_sectors - sector_num; - if (nb_sectors <= 0) + if (nb_sectors <= 0) { break; - if (nb_sectors >= (IO_BUF_SIZE / 512)) + } + if (nb_sectors >= (IO_BUF_SIZE / 512)) { n = (IO_BUF_SIZE / 512); - else + } else { n = nb_sectors; + } while (sector_num - bs_offset >= bs_sectors) { bs_i ++; @@ -945,8 +957,9 @@ static int img_convert(int argc, char **argv) sector_num, bs_i, bs_offset, bs_sectors); */ } - if (n > bs_offset + bs_sectors - sector_num) + if (n > bs_offset + bs_sectors - sector_num) { n = bs_offset + bs_sectors - sector_num; + } if (has_zero_init) { /* If the output image is being created as a copy on write image, @@ -1082,8 +1095,9 @@ static int img_info(int argc, char **argv) fmt = NULL; for(;;) { c = getopt(argc, argv, "f:h"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -1093,8 +1107,9 @@ static int img_info(int argc, char **argv) break; } } - if (optind >= argc) + if (optind >= argc) { help(); + } filename = argv[optind++]; bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING); @@ -1105,11 +1120,12 @@ static int img_info(int argc, char **argv) bdrv_get_geometry(bs, &total_sectors); get_human_readable_size(size_buf, sizeof(size_buf), total_sectors * 512); allocated_size = get_allocated_file_size(filename); - if (allocated_size < 0) + if (allocated_size < 0) { snprintf(dsize_buf, sizeof(dsize_buf), "unavailable"); - else + } else { get_human_readable_size(dsize_buf, sizeof(dsize_buf), allocated_size); + } printf("image: %s\n" "file format: %s\n" "virtual size: %s (%" PRId64 " bytes)\n" @@ -1117,11 +1133,13 @@ static int img_info(int argc, char **argv) filename, fmt_name, size_buf, (total_sectors * 512), dsize_buf); - if (bdrv_is_encrypted(bs)) + if (bdrv_is_encrypted(bs)) { printf("encrypted: yes\n"); + } if (bdrv_get_info(bs, &bdi) >= 0) { - if (bdi.cluster_size != 0) + if (bdi.cluster_size != 0) { printf("cluster_size: %d\n", bdi.cluster_size); + } } bdrv_get_backing_filename(bs, backing_filename, sizeof(backing_filename)); if (backing_filename[0] != '\0') { @@ -1154,8 +1172,9 @@ static int img_snapshot(int argc, char **argv) /* Parse commandline parameters */ for(;;) { c = getopt(argc, argv, "la:c:d:h"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -1195,8 +1214,9 @@ static int img_snapshot(int argc, char **argv) } } - if (optind >= argc) + if (optind >= argc) { help(); + } filename = argv[optind++]; /* Open the image */ @@ -1220,23 +1240,26 @@ static int img_snapshot(int argc, char **argv) sn.date_nsec = tv.tv_usec * 1000; ret = bdrv_snapshot_create(bs, &sn); - if (ret) + if (ret) { error("Could not create snapshot '%s': %d (%s)", snapshot_name, ret, strerror(-ret)); + } break; case SNAPSHOT_APPLY: ret = bdrv_snapshot_goto(bs, snapshot_name); - if (ret) + if (ret) { error("Could not apply snapshot '%s': %d (%s)", snapshot_name, ret, strerror(-ret)); + } break; case SNAPSHOT_DELETE: ret = bdrv_snapshot_delete(bs, snapshot_name); - if (ret) + if (ret) { error("Could not delete snapshot '%s': %d (%s)", snapshot_name, ret, strerror(-ret)); + } break; } @@ -1264,8 +1287,9 @@ static int img_rebase(int argc, char **argv) for(;;) { c = getopt(argc, argv, "uhf:F:b:"); - if (c == -1) + if (c == -1) { break; + } switch(c) { case 'h': help(); @@ -1285,8 +1309,9 @@ static int img_rebase(int argc, char **argv) } } - if ((optind >= argc) || !out_baseimg) + if ((optind >= argc) || !out_baseimg) { help(); + } filename = argv[optind++]; /*