From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08cn-0003op-Rj for qemu-devel@nongnu.org; Fri, 19 Jul 2013 07:13:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V08cl-0005ZA-V7 for qemu-devel@nongnu.org; Fri, 19 Jul 2013 07:13:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64232) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08cl-0005Z5-M1 for qemu-devel@nongnu.org; Fri, 19 Jul 2013 07:13:23 -0400 Message-ID: <51E91F4F.9090400@redhat.com> Date: Fri, 19 Jul 2013 05:13:19 -0600 From: Eric Blake MIME-Version: 1.0 References: <1374201401-11244-1-git-send-email-p.pawit@gmail.com> <51E91BAF.4050903@redhat.com> In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="UEj7gtm8FmuqUB1gj7ATicIJQWVDOn09L" Subject: Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pawit Pornkitprasan Cc: Ryousei Takano , qemu-devel@nongnu.org, Juan Quintela This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --UEj7gtm8FmuqUB1gj7ATicIJQWVDOn09L Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 07/19/2013 05:04 AM, Pawit Pornkitprasan wrote: > On Fri, Jul 19, 2013 at 7:57 PM, Eric Blake wrote: >> >> However, wouldn't it be nice if we improved the qapi generator to >> guarantee a sane default value for optional parameters, even when >> has_value is false? >> >=20 > I'm not a qemu expert or anything, but wouldn't that destroy the point > of has_value in the first place? There are two uses for has_value. One: on output, the user knows whether the variable has been set to anything sane. Two: on input, the receiver knows if the caller passed an optional value. For output, has_value is always needed. But for input, we could probably simplify a LOT of code if 'value' already had a sane default of 0, without having to first check 'has_value', instead of the current state where 'value' must be treated as uninitialized if 'has_value' is false. Improving the qapi generator to guarantee 0 value of optional parameters that were not specified in JSON should not block your patch (it would be a series by itself), it's just a question of whether it is worth making the change and the resulting simplifications we can make to code that can assume sane default values. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --UEj7gtm8FmuqUB1gj7ATicIJQWVDOn09L Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJR6R9PAAoJEKeha0olJ0NqwcIH/1DrS/tonDe049ZzG88ZwZIS mTkDjKRkuy4Nj7Xg+f2iunTTS+iKT/RKpA+Ght9H5BpbSOOlX0EdkU2/NPwnIRmW DWeZHs0WITgl4BuD/KphyAjU7je0vcSRvuOLYIfMsfrNuB7EHgLkN8FLK0xEcW8Z Lepg7LCTRAom4GSGniVnrWSj85WzbYPsqEYKoi/K84Ilq+eu9vZfjBmc5HuuoHEX qC7I+P1pla+M3kKY6qGYykUmPsD+IR750VuSxP+XVJTXVGJ6C2qKp1f8yHlCqTvo tCkXEfFeezQPxIQwmquTMLs1D1dUs889ivC7+5nY1M7FLjLes2mEmnpRC9rp3Gg= =Rz2b -----END PGP SIGNATURE----- --UEj7gtm8FmuqUB1gj7ATicIJQWVDOn09L--