WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxl: correct error path in libxl_userda

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxl: correct error path in libxl_userdata_retrieve
From: Xen patchbot-unstable <patchbot@xxxxxxx>
Date: Sat, 29 Jan 2011 15:05:52 -0800
Delivery-date: Sat, 29 Jan 2011 15:12:25 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
# Date 1296233033 0
# Node ID 4fea7664a6fbc0299f813d40395f5b50491314a4
# Parent  722f7b7678dcdf3d522d7875a26491e2272aa66d
libxl: correct error path in libxl_userdata_retrieve

Firstly, if libxl_read_file_contents fails, it doesn't really leave
*data and *datalen_r undefined - it leaves them unchanged.  Tighten up
the spec for the benefit of libxl_userdata_retrieve.

Secondly, libxl_userdata_retrieve ignored errors, assuming they were
all ENOENT.  Instead it should fail on unexpected errors.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Acked-by: Jim Fehlig <jfehlig@xxxxxxxxxx>
Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_dom.c   |    5 ++++-
 tools/libxl/libxl_utils.h |    2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff -r 722f7b7678dc -r 4fea7664a6fb tools/libxl/libxl_dom.c
--- a/tools/libxl/libxl_dom.c   Fri Jan 28 11:08:49 2011 +0000
+++ b/tools/libxl/libxl_dom.c   Fri Jan 28 16:43:53 2011 +0000
@@ -671,7 +671,10 @@ int libxl_userdata_retrieve(libxl_ctx *c
     }
 
     e = libxl_read_file_contents(ctx, filename, data_r ? &data : 0, &datalen);
-
+    if (e && errno != ENOENT) {
+        rc = ERROR_FAIL;
+        goto out;
+    }
     if (!e && !datalen) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "userdata file %s is empty", 
filename);
         if (data_r) assert(!*data_r);
diff -r 722f7b7678dc -r 4fea7664a6fb tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Fri Jan 28 11:08:49 2011 +0000
+++ b/tools/libxl/libxl_utils.h Fri Jan 28 16:43:53 2011 +0000
@@ -36,7 +36,7 @@ int libxl_read_file_contents(libxl_ctx *
   /* Reads the contents of the plain file filename into a mallocd
    * buffer.  Returns 0 or errno.  Any errors other than ENOENT are logged.
    * If the file is empty, *data_r and *datalen_r are set to 0.
-   * On error, *data_r and *datalen_r are undefined.
+   * On error, *data_r and *datalen_r are unchanged.
    * data_r and/or datalen_r may be 0.
    */
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxl: correct error path in libxl_userdata_retrieve, Xen patchbot-unstable <=