From: Ian Jackson Subject: Re: [Patch v3 3/4] tools/libxl: Fix libxl__device_nic_from_xs_be() Date: Tue, 26 Nov 2013 11:32:36 +0000 Message-ID: <21140.34516.685325.920576@mariner.uk.xensource.com> References: <52939C67.7020108@citrix.com> <1385412567-7717-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1385412567-7717-1-git-send-email-andrew.cooper3@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: Andrew Cooper Cc: Roger Pau Monne , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org Andrew Cooper writes ("[Xen-devel] [Patch v3 3/4] tools/libxl: Fix libxl__device_nic_from_xs_be()"): > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c > - tmp = xs_read(ctx->xsh, XBT_NULL, > - libxl__sprintf(gc, "%s/handle", be_path), &len); > - if ( tmp ) > + rc = libxl__xs_read_checked(gc, XBT_NULL, > + libxl__sprintf(gc, "%s/handle", be_path), > + &tmp); > + > + if ((rc == 0) && strlen(tmp)) Nacked-by: Ian Jackson (for the benefit of Ian C.) This is not correct. See the doc comment for libxl__xs_read_checked: /* On success, *result_out came from the gc. * On error, *result_out is undefined. * ENOENT counts as success but sets *result_out=0 */ int libxl__xs_read_checked(libxl__gc *gc, xs_transaction_t t, const char *path, const char **result_out); So the correct pattern is: rc = libxl__xs_read_checked(gc, XBT_NULL, blah blah blah, &tmp); if (rc) goto out; if (tmp) { use tmp; } else { the path doesn't exist, do the other thing; } I don't think there should be any need to check for empty strings written to xenstore here ? The old code doesn't. Please someone tell me there isn't. Thanks, Ian.