From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH for-4.6 08/13] xl: call libxl_dominfo_init in main_list Date: Thu, 23 Jul 2015 10:44:38 +0100 Message-ID: <1437644678.19412.79.camel@citrix.com> References: <1437638354-14216-1-git-send-email-wei.liu2@citrix.com> <1437638354-14216-9-git-send-email-wei.liu2@citrix.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 1ZID3T-0000yu-CX for xen-devel@lists.xenproject.org; Thu, 23 Jul 2015 09:44:43 +0000 In-Reply-To: <1437638354-14216-9-git-send-email-wei.liu2@citrix.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: Wei Liu , Xen-devel Cc: Ian Jackson List-Id: xen-devel@lists.xenproject.org On Thu, 2015-07-23 at 08:59 +0100, Wei Liu wrote: > Also change the path that disposes of the buffer to use info_buf to > avoid confusing coverity. > > Signed-off-by: Wei Liu Acked-by: Ian Campbell But would it be less confusing to both human and machine readers if info_buf was always init'd and dispose'd unconditionally at the head and tail of the function? i.e. ignoring the fact that in one code path we use a different info? > --- > tools/libxl/xl_cmdimpl.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index a4e56ef..79cef7a 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -4843,6 +4843,8 @@ int main_list(int argc, char **argv) > info_free = info; > } else if (optind == argc-1) { > uint32_t domid = find_domain(argv[optind]); > + > + libxl_dominfo_init(&info_buf); > rc = libxl_domain_info(ctx, &info_buf, domid); > if (rc == ERROR_DOMAIN_NOTFOUND) { > fprintf(stderr, "Error: Domain \'%s\' does not > exist.\n", > @@ -4869,7 +4871,7 @@ int main_list(int argc, char **argv) > if (info_free) > libxl_dominfo_list_free(info, nb_domain); > else > - libxl_dominfo_dispose(info); > + libxl_dominfo_dispose(&info_buf); > > return 0; > }