From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH 1/4] libxl: Use libxl_strdup instead of strdup on libxl_version_info Date: Mon, 1 Feb 2016 12:13:59 +0000 Message-ID: <20160201121359.GV25660@citrix.com> References: <1453843860-29591-1-git-send-email-konrad.wilk@oracle.com> <1453843860-29591-2-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQDMp-0004Lv-Re for xen-devel@lists.xenproject.org; Mon, 01 Feb 2016 12:14:03 +0000 Content-Disposition: inline In-Reply-To: <1453843860-29591-2-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Konrad Rzeszutek Wilk Cc: Ian.Jackson@eu.citrix.com, xen-devel@lists.xenproject.org, wei.liu2@citrix.com, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org On Tue, Jan 26, 2016 at 04:30:57PM -0500, Konrad Rzeszutek Wilk wrote: > The change is simple replace of raw strdup with a libxl variant. > The benefit of that is the libxl variant has the extra > behaviour of abort-on-alloc-fail - and will improve error handling. > > libxl_version_info is a bit odd - it is a public function and as libxl.h > mentions - the callers of libxl_ public function needs to call the appropiate > _dispose() function. > > "However libxl_get_version_info() is special and returns a cached > result from the ctx which cannot and should not be freed (as evidenced > by it returning a const struct). This data is freed in libxl_ctx_free() > by calling libxl_version_info_dispose(). This is why none of the callers > remember to free -- they shouldn't be doing so." (Ian Campbell) > > So the patch makes sure to use the NOGC. > > Suggested-by: Wei Liu > Signed-off-by: Konrad Rzeszutek Wilk Acked-by: Wei Liu