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:
parent
4b69d4c3d7
commit
e08a5241d3
@ -562,19 +562,20 @@ static void qobject_input_type_number_keyval(Visitor *v, const char *name,
|
|||||||
{
|
{
|
||||||
QObjectInputVisitor *qiv = to_qiv(v);
|
QObjectInputVisitor *qiv = to_qiv(v);
|
||||||
const char *str = qobject_input_get_keyval(qiv, name, errp);
|
const char *str = qobject_input_get_keyval(qiv, name, errp);
|
||||||
char *endp;
|
double val;
|
||||||
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = 0;
|
if (qemu_strtod_finite(str, NULL, &val)) {
|
||||||
*obj = strtod(str, &endp);
|
|
||||||
if (errno || endp == str || *endp || !isfinite(*obj)) {
|
|
||||||
/* TODO report -ERANGE more nicely */
|
/* TODO report -ERANGE more nicely */
|
||||||
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
|
||||||
full_name(qiv, name), "number");
|
full_name(qiv, name), "number");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*obj = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
|
static void qobject_input_type_any(Visitor *v, const char *name, QObject **obj,
|
||||||
|
Loading…
Reference in New Issue
Block a user