[Qemu-devel] [PATCH] correct error message qemu-img reported

2012-11-01 Thread 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 lig.f...@cn.fujitsu.com
---
 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.);
-- 
1.7.1




Re: [Qemu-devel] [PATCH] correct error message qemu-img reported

2012-11-01 Thread Wei-Ren Chen
On Fri, Nov 02, 2012 at 10:35:50AM +0800, liguang wrote:
 qemu-img will complain when qcow or qcow2
 size overflow for 64 bits, report the right
 message in this condition.
 
 Signed-off-by: liguang lig.f...@cn.fujitsu.com
 ---
  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);
^^^
  wrong ident?

 +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.);
 -- 
 1.7.1
 

-- 
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj



Re: [Qemu-devel] [PATCH] correct error message qemu-img reported

2012-11-01 Thread li guang
在 2012-11-02五的 11:12 +0800,陳韋任 (Wei-Ren Chen)写道:
 On Fri, Nov 02, 2012 at 10:35:50AM +0800, liguang wrote:
  qemu-img will complain when qcow or qcow2
  size overflow for 64 bits, report the right
  message in this condition.
  
  Signed-off-by: liguang lig.f...@cn.fujitsu.com
  ---
   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);
 ^^^
   wrong ident?

   Yep, strange indent, will re-send it.
   Thanks!

 
  +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.);
  -- 
  1.7.1
  
 

-- 
liguanglig.f...@cn.fujitsu.com
FNST linux kernel team




[Qemu-devel] [PATCH] correct error message qemu-img reported

2012-11-01 Thread 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 lig.f...@cn.fujitsu.com
---
 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




[Qemu-devel] [PATCH] correct error message qemu-img reported

2012-11-01 Thread 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 lig.f...@cn.fujitsu.com
---
 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