From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3udL-0001jz-9Q for qemu-devel@nongnu.org; Mon, 29 Jul 2013 17:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3udF-0002Yp-4M for qemu-devel@nongnu.org; Mon, 29 Jul 2013 17:05:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59636) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3udE-0002Yk-SS for qemu-devel@nongnu.org; Mon, 29 Jul 2013 17:05:29 -0400 Date: Mon, 29 Jul 2013 17:05:23 -0400 From: Luiz Capitulino Message-ID: <20130729170523.4e6a62eb@redhat.com> In-Reply-To: <51E91BAF.4050903@redhat.com> References: <1374201401-11244-1-git-send-email-p.pawit@gmail.com> <51E91BAF.4050903@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Pawit Pornkitprasan , qemu-devel@nongnu.org, Ryousei Takano , Juan Quintela On Fri, 19 Jul 2013 04:57:51 -0600 Eric Blake wrote: > On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote: > > The qmp_migrate method uses the 'blk' and 'inc' parameter without > > checking if they're valid or not (they may be uninitialized if > > command is received via QMP) > > > > Signed-off-by: Pawit Pornkitprasan > > --- > > migration.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > Reviewed-by: Eric Blake > > 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? We could do that for bool and pointers, but this wouldn't help integers and enums. Also, even if we had default values, I guess I'd enforce a common idiom for handling optionals as this is also a good practice for preventing bugs.