From: Ian Campbell Subject: Re: [PATCH] libxl: initialize domid to 0 in libxl__create_stubdom Date: Thu, 9 Jun 2011 08:55:21 +0100 Message-ID: <1307606121.775.761.camel@zakaz.uk.xensource.com> References: <1307595829.8990.9.camel@limbo> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1307595829.8990.9.camel@limbo> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Wei Liu Cc: "xen-devel@lists.xensource.com" , Stabellini Stefano List-Id: xen-devel@lists.xenproject.org On Thu, 2011-06-09 at 06:03 +0100, Wei Liu wrote: > The uninitialized domid may cause libxl__domain_make to fail. > > In libxl__domain_make: > assert(!libxl_domid_valid_guest(*domid)). > > Signed-off-by: Wei Liu That check seems pretty odd to me at first but the commit message of 22842:ccfa0527893e does a good job of explaining why so: Acked-by: Ian Campbell although it's not clear why libxl__domain_make doesn't just set an invalid value as it's first act and save the callers the effort, the net result would still be the correct semantics for libxl_domid_valid_guest when the function exits. Ian. > > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c > index 47a51c8..fbee1d0 100644 > --- a/tools/libxl/libxl_dm.c > +++ b/tools/libxl/libxl_dm.c > @@ -570,7 +570,7 @@ static int libxl__create_stubdom(libxl__gc *gc, > libxl_domain_create_info c_info; > libxl_domain_build_info b_info; > libxl__domain_build_state state; > - uint32_t domid; > + uint32_t domid = 0; > char **args; > struct xs_permissions perm[2]; > xs_transaction_t t; > >