aboutsummaryrefslogtreecommitdiff
path: root/qapi/qobject-input-visitor.c
diff options
context:
space:
mode:
authorDavid Hildenbrand <david@redhat.com>2018-11-21 17:44:16 +0100
committerMarkus Armbruster <armbru@redhat.com>2018-12-13 19:10:06 +0100
commite08a5241d303d668b9f653344537eccb8b620663 (patch)
tree969523315fa7266d11ccc715d99411fcdfc2fe22 /qapi/qobject-input-visitor.c
parent4b69d4c3d7c133ebc9393ef3f86ce38831921cb6 (diff)
qapi: Use qemu_strtod_finite() in qobject-input-visitor
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 <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20181121164421.20780-5-david@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Diffstat (limited to 'qapi/qobject-input-visitor.c')
-rw-r--r--qapi/qobject-input-visitor.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 3e88b27f9e..07465f9947 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -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,