Skip to contentSkip to conversation

correct error message qemu-img reported

PATCH In review liguang 2 participants 3 messages Nov 2, 2012

lore
Share & tools
lore

liguang

author
#0 lore raw

PATCH 1/1 correct error message qemu-img reported

qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

---
 qemu-img.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
qemu-img.c +4 -2
index f17f187..a332467 100644
@@ -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.");
Signature · 1 line
1.7.1
#1 lore raw
Quoted 14 lines · liguang

qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

---
 qemu-img.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
qemu-img.c +0 -0
index f17f187..a332467 100644

qemu-img.c static int img_create(int argc, char **argv) · line 350

Quoted 10 lines
qemu-img.c +3 -2
@@ -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?

Quoted 7 lines
qemu-img.c +1 -0
+        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.");
Signature · 1 line
1.7.1
Signature · 5 lines
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
author
#2 lore raw
Quoted 26 lines · 在 2012-11-02五的 11:12 +0800,陳韋任 (Wei-Ren Chen)写道:
Quoted 14 lines · liguang

qemu-img will complain when qcow or qcow2
size overflow for 64 bits, report the right
message in this condition.

---
 qemu-img.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
qemu-img.c +0 -0
index f17f187..a332467 100644

qemu-img.c static int img_create(int argc, char **argv) · line 350

Quoted 10 lines
qemu-img.c +3 -2
@@ -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");
    ^^^
Quoted 1 line

wrong ident?

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

Quoted 9 lines
Quoted 8 lines
qemu-img.c +1 -0
+        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.");
Signature · 1 line
1.7.1
Signature · 2 lines
liguang    [email protected]
FNST linux kernel team