From: Ian Jackson Subject: Re: Re: [PATCH] libxl: initialize domid to 0 in libxl__create_stubdom Date: Tue, 21 Jun 2011 15:25:02 +0100 Message-ID: <19968.43454.234108.5386@mariner.uk.xensource.com> References: <1307595829.8990.9.camel@limbo> <1307606121.775.761.camel@zakaz.uk.xensource.com> <1307608287.31235.17.camel@limbo> <1307615031.775.810.camel@zakaz.uk.xensource.com> <19963.37638.19033.472036@mariner.uk.xensource.com> <19968.36303.693667.57932@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Stefano Stabellini Cc: Ian Campbell , "xen-devel@lists.xensource.com" , Wei Liu List-Id: xen-devel@lists.xenproject.org Stefano Stabellini writes ("Re: [Xen-devel] Re: [PATCH] libxl: initialize domid to 0 in libxl__create_stubdom"): > I understand what you mean, but in that case I would rather have the > check right before allocate: > > assert(!libxl_domid_valid_guest(*domid)); > something = allocate(); > > in the outer function. What? Are you proposing this: char *something = NULL; uint32_t domid = -1; ... assert(!libxl_domid_valid_guest(*domid)); assert(!something); ... something = allocate(); if (!something) goto error_exit; ... ret = libxl__domain_make(&domid); if (ret) goto error_exit; ... return successfully somehow; error_exit: free(something); if (libxl_domid_valid_guest(domid)) libxl_domain_destroy(domid); What would be the point of that ? > Because libxl__domain_make doesn't have any business in checking for the > validity of an output parameter, it is a layering violation. I'm proposing that this should be an update parameter. Ian.