From: Jes.Sorensen@redhat.com
To: kwolf@redhat.com
Cc: stefanha@linux.vnet.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 2/3] Fix formatting and missing braces in qemu-img.c
Date: Mon, 6 Dec 2010 09:17:35 +0100 [thread overview]
Message-ID: <1291623456-3826-3-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1291623456-3826-1-git-send-email-Jes.Sorensen@redhat.com>
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
qemu-img.c | 77 +++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 51 insertions(+), 26 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 7863835..2a54ae2 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, "?")) {
@@ -471,8 +473,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();
@@ -482,8 +485,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);
@@ -547,8 +551,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();
@@ -558,8 +563,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);
@@ -683,8 +689,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();
@@ -717,7 +724,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];
@@ -908,8 +917,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);
@@ -929,12 +939,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 ++;
@@ -946,8 +958,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++];
/*
--
1.7.3.2
next prev parent reply other threads:[~2010-12-06 8:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-06 8:17 [Qemu-devel] [PATCH v2 0/3] Cleanup qemu-img code Jes.Sorensen
2010-12-06 8:17 ` [Qemu-devel] [PATCH 1/3] Consolidate printing of block driver options Jes.Sorensen
2010-12-06 9:32 ` Stefan Hajnoczi
2010-12-06 10:20 ` Jes Sorensen
2010-12-06 10:37 ` Stefan Hajnoczi
2010-12-06 10:47 ` Jes Sorensen
2010-12-06 11:04 ` Stefan Hajnoczi
2010-12-06 8:17 ` Jes.Sorensen [this message]
2010-12-06 8:17 ` [Qemu-devel] [PATCH 3/3] Fail if detecting an unknown option Jes.Sorensen
2010-12-06 9:24 ` Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2010-12-02 17:46 [Qemu-devel] [PATCH 0/3] Cleanup qemu-img code Jes.Sorensen
2010-12-02 17:46 ` [Qemu-devel] [PATCH 2/3] Fix formatting and missing braces in qemu-img.c Jes.Sorensen
2010-12-03 11:04 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1291623456-3826-3-git-send-email-Jes.Sorensen@redhat.com \
--to=jes.sorensen@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).