Received: from eggs.gnu.org ([208.118.235.92]:37930) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU80u-0002Vr-UC for qemu-devel@nongnu.org; Thu, 01 Nov 2012 23:33:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TU80t-0006p3-Id for qemu-devel@nongnu.org; Thu, 01 Nov 2012 23:33:44 -0400 Received: from [222.73.24.84] (port=46878 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TU80t-0006ot-7O for qemu-devel@nongnu.org; Thu, 01 Nov 2012 23:33:43 -0400 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id qA23XfUk002303 for ; Fri, 2 Nov 2012 11:33:41 +0800 From: liguang Date: Fri, 2 Nov 2012 11:32:47 +0800 Message-Id: <1351827167-21171-1-git-send-email-lig.fnst@cn.fujitsu.com> Subject: [Qemu-devel] [PATCH] correct error message qemu-img reported List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: liguang 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 | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index f17f187..2a45427 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -343,15 +343,17 @@ 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) { - error_report("Invalid image size specified! You may use k, M, G or " - "T suffixes for "); - error_report("kilobytes, megabytes, gigabytes and terabytes."); - ret = -1; - goto out; + 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."); + ret = -1; + goto out; } img_size = (uint64_t)sval; } -- 1.7.1