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>
This commit is contained in:
David Hildenbrand 2018-11-21 17:44:16 +01:00 committed by Markus Armbruster
parent 4b69d4c3d7
commit e08a5241d3

View 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,