From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNIGo-0005bk-AX for qemu-devel@nongnu.org; Thu, 15 Nov 2018 09:05:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNIGj-0004Le-Ow for qemu-devel@nongnu.org; Thu, 15 Nov 2018 09:05:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18925) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNIGj-0004L5-K2 for qemu-devel@nongnu.org; Thu, 15 Nov 2018 09:05:17 -0500 From: David Hildenbrand Date: Thu, 15 Nov 2018 15:04:55 +0100 Message-Id: <20181115140501.7872-4-david@redhat.com> In-Reply-To: <20181115140501.7872-1-david@redhat.com> References: <20181115140501.7872-1-david@redhat.com> Subject: [Qemu-devel] [PATCH v1 3/9] qapi: use qemu_strtod_finite() in string-input-visitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Markus Armbruster , Michael Roth , Eric Blake , Paolo Bonzini , David Hildenbrand Let's use the new function. "NaN" and "inf" are now properly rejected. Signed-off-by: David Hildenbrand --- qapi/string-input-visitor.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qapi/string-input-visitor.c b/qapi/string-input-visitor.c index b3fdd0827d..b89c6c4e06 100644 --- a/qapi/string-input-visitor.c +++ b/qapi/string-input-visitor.c @@ -20,6 +20,7 @@ #include "qemu/option.h" #include "qemu/queue.h" #include "qemu/range.h" +#include "qemu/cutils.h" struct StringInputVisitor @@ -313,12 +314,9 @@ static void parse_type_number(Visitor *v, const char *name, double *obj, Error **errp) { StringInputVisitor *siv = to_siv(v); - char *endp = (char *) siv->string; double val; - errno = 0; - val = strtod(siv->string, &endp); - if (errno || endp == siv->string || *endp) { + if (qemu_strtod_finite(siv->string, NULL, &val)) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null", "number"); return; -- 2.17.2