From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39444) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiP2o-00053O-RL for qemu-devel@nongnu.org; Tue, 22 Mar 2016 12:20:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiP2j-0000bp-TJ for qemu-devel@nongnu.org; Tue, 22 Mar 2016 12:20:34 -0400 References: <1457635927-23045-1-git-send-email-berrange@redhat.com> <1457636396-24983-1-git-send-email-berrange@redhat.com> <1457636396-24983-2-git-send-email-berrange@redhat.com> <56F08129.60807@redhat.com> <20160322154940.GI25450@redhat.com> From: Eric Blake Message-ID: <56F170C0.80500@redhat.com> Date: Tue, 22 Mar 2016 10:20:16 -0600 MIME-Version: 1.0 In-Reply-To: <20160322154940.GI25450@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FO3XE7A6n1HTqoxFO1lsKcKj1pX39eSd4" Subject: Re: [Qemu-devel] [PATCH v3 02/10] qapi: allow QmpInputVisitor to auto-cast types List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-block@nongnu.org, Markus Armbruster , qemu-devel@nongnu.org, Paolo Bonzini , Max Reitz , =?UTF-8?Q?Andreas_F=c3=a4rber?= This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FO3XE7A6n1HTqoxFO1lsKcKj1pX39eSd4 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 03/22/2016 09:49 AM, Daniel P. Berrange wrote: > On Mon, Mar 21, 2016 at 05:18:01PM -0600, Eric Blake wrote: >> On 03/10/2016 11:59 AM, Daniel P. Berrange wrote: >>> Currently the QmpInputVisitor assumes that all scalar >>> values are directly represented as their final types. >>> ie it assumes an 'int' is using QInt, and a 'bool' is >>> using QBool. >>> >>> This extends it so that QString is optionally permitted >>> for any of the non-string scalar types. This behaviour >>> is turned on by requesting the 'autocast' flag in the >>> constructor. >>> >> Hmm. Do we need to worry about partial asymmetry? That is, >> qint_get_int() returns a signed number, but qemu_strtoull() parses >> unsigned; if the original conversion from JSON to qint uses a differen= t >> parser, then we could have funny results where we get different result= s >> for things like: >> "key1":9223372036854775807, "key2":"9223372036854775807", >> even though the same string of digits is being parsed, based on whethe= r >> the different parsers handle numbers larger than INT64_MAX differently= =2E >=20 > Is this something you want me to change for re-post, or just a general > point for future ? ie should I be using qemu_strtoll instead of > qemu_strtoull or something else ? qint itself doesn't seem > to concern itself with parsing ints from strintgs, so presumably > this is from json code ? General comment for now. We already know we need a bigger audit of handling of values larger than INT64_MAX, so any cleanups related to that can be deferred to that later audit. But maybe a FIXME or TODO comment in the code in your submission, to remind us to think about it during the later audit, would help. >>> + qstr =3D qobject_to_qstring(qobj); >>> + if (qstr && qstr->string && qiv->autocast) { >>> + if (!strcasecmp(qstr->string, "on") || >>> + !strcasecmp(qstr->string, "yes") || >>> + !strcasecmp(qstr->string, "true")) { >>> + *obj =3D true; >>> + return; >>> + } >> >> Do we also want to allow "0"/"1" for true/false? >=20 > These 3 strings I took from opts-visitor.c, so to maintain compat > we probably should not allow 0/1, unless we decide to extend > opts-visitor too Good point. Maybe a comment pointing in both places pointing out that we should keep them in sync is a worthwhile addition. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --FO3XE7A6n1HTqoxFO1lsKcKj1pX39eSd4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJW8XDAAAoJEKeha0olJ0Nq6FEH/0jWQB0U2Xk0I73youDNxMnT lNpu8LXDSGEcPTZPo1ecMIb/9JbLy9CzGl+Gpwg2Z5aRROZZMHEz7u92EIlL608x 6FigaooEG1spgqm0cvVQKlaNtxoiAix9Jw/zoEM8gZNl2FR4miX9c0Pud54P+tEH 3HXS0UC8lw5Gp1xsBrJNGBJNm9AOIcR4XrlTR2smEsW0nyRf8E0otd4bdoNcSWBQ zC2RZ7Zg0ZBLdeCjTBDyfW6/f18vSJAuXHHwSAutG4IrLZhrjH8jcEJtceNdra5F G/LD3elP1Q0HMAoUNR8EhCWkDfxPGiaMMYZBc4Zt0XKBVQkgRzjSYqYAmOQPHHc= =NVp6 -----END PGP SIGNATURE----- --FO3XE7A6n1HTqoxFO1lsKcKj1pX39eSd4--