From patchwork Fri Nov 2 02:35:50 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: correct error message qemu-img reported From: liguang X-Patchwork-Id: 196467 Message-Id: <1351823750-30515-1-git-send-email-lig.fnst@cn.fujitsu.com> To: qemu-devel@nongnu.org Cc: liguang Date: Fri, 2 Nov 2012 10:35:50 +0800 qemu-img will complain when qcow or qcow2 size overflow for 64 bits, report the right message in this condition. Signed-off-by: liguang --- qemu-img.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index f17f187..a332467 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -343,10 +343,12 @@ static int img_create(int argc, char **argv) /* Get image size, if specified */ if (optind < argc) { - int64_t sval; + int64_t sval = 0; char *end; sval = strtosz_suffix(argv[optind++], &end, STRTOSZ_DEFSUFFIX_B); - if (sval < 0 || *end) { + if (sval < 0) + error_report("image size is too large!\n"); + if (*end) { error_report("Invalid image size specified! You may use k, M, G or " "T suffixes for "); error_report("kilobytes, megabytes, gigabytes and terabytes.");