qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] qapi: treat all negative return of strtosz_suffix()


From: Amos Kong
Subject: [Qemu-devel] [PATCH] qapi: treat all negative return of strtosz_suffix() as error
Date: Mon, 28 Apr 2014 00:16:02 +0800

String "-3" will be wrongly converted to -34 by strtosz_suffix().
strtosz_suffix_unit() only returns integer in success situation.

Signed-off-by: Amos Kong <address@hidden>
---
 qapi/opts-visitor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c
index 5d830a2..881e1b9 100644
--- a/qapi/opts-visitor.c
+++ b/qapi/opts-visitor.c
@@ -472,7 +472,7 @@ opts_type_size(Visitor *v, uint64_t *obj, const char *name, 
Error **errp)
 
     val = strtosz_suffix(opt->str ? opt->str : "", &endptr,
                          STRTOSZ_DEFSUFFIX_B);
-    if (val != -1 && *endptr == '\0') {
+    if (val >= 0 && *endptr == '\0') {
         *obj = val;
         processed(ov, name);
         return;
-- 
1.9.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]