提交 e08a5241 编写于 作者: D David Hildenbrand 提交者: Markus Armbruster

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: NEric Blake <eblake@redhat.com>
Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
Signed-off-by: NDavid Hildenbrand <david@redhat.com>
Message-Id: <20181121164421.20780-5-david@redhat.com>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
上级 4b69d4c3
......@@ -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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册