]> Git Repo - qemu.git/commitdiff
qapi: Use qemu_strtod_finite() in qobject-input-visitor
authorDavid Hildenbrand <[email protected]>
Wed, 21 Nov 2018 16:44:16 +0000 (17:44 +0100)
committerMarkus Armbruster <[email protected]>
Thu, 13 Dec 2018 18:10:06 +0000 (19:10 +0100)
Let's use the new function. Just as current behavior, we have to
consume the whole string (now it's just way clearer what's going on).

Reviewed-by: Eric Blake <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Message-Id: <20181121164421[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
qapi/qobject-input-visitor.c

index 3e88b27f9e64ff4be5ec7b791ae06febb44dd34b..07465f9947821e1cd90af3e450ba24ba535ba2b2 100644 (file)
@@ -562,19 +562,20 @@ static void qobject_input_type_number_keyval(Visitor *v, const char *name,
 {
     QObjectInputVisitor *qiv = to_qiv(v);
     const char *str = qobject_input_get_keyval(qiv, name, errp);
-    char *endp;
+    double val;
 
     if (!str) {
         return;
     }
 
-    errno = 0;
-    *obj = strtod(str, &endp);
-    if (errno || endp == str || *endp || !isfinite(*obj)) {
+    if (qemu_strtod_finite(str, NULL, &val)) {
         /* TODO report -ERANGE more nicely */
         error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
                    full_name(qiv, name), "number");
+        return;
     }
+
+    *obj = val;
 }
 
 static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
This page took 0.0312 seconds and 4 git commands to generate.