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] Change read and list to return None if key/dir doesn't e

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Change read and list to return None if key/dir doesn't exist.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Sep 2005 17:50:10 +0000
Delivery-date: Tue, 13 Sep 2005 17:48:38 +0000
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID c66a660872e7ab730e4e35dc613280530713fca6
# Parent  89ed236b6b66a66e2f0b0fb977e48cd943ce9dc1
Change read and list to return None if key/dir doesn't exist.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 89ed236b6b66 -r c66a660872e7 tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Tue Sep 13 10:42:15 2005
+++ b/tools/python/xen/lowlevel/xs/xs.c Tue Sep 13 14:45:34 2005
@@ -74,6 +74,7 @@
        " path [string]: xenstore path\n"       \
        "\n"                                    \
        "Returns: [string] data read.\n"        \
+       "         None if key doesn't exist.\n" \
        "Raises RuntimeError on error.\n"       \
        "\n"
 
@@ -97,7 +98,11 @@
     xsval = xs_read(xh, path, &xsval_n);
     Py_END_ALLOW_THREADS
     if (!xsval) {
-        PyErr_SetFromErrno(PyExc_RuntimeError);
+        if (errno == ENOENT) {
+            Py_INCREF(Py_None);
+            val = Py_None;
+        } else
+            PyErr_SetFromErrno(PyExc_RuntimeError);
         goto exit;
     }
     val = PyString_FromStringAndSize(xsval, xsval_n);
@@ -160,6 +165,7 @@
        " path [string]: path to list.\n"                       \
        "\n"                                                    \
        "Returns: [string array] list of subdirectory names.\n" \
+       "         None if key doesn't exist.\n"                 \
        "Raises RuntimeError on error.\n"                       \
        "\n"
 
@@ -183,12 +189,17 @@
     xsval = xs_directory(xh, path, &xsval_n);
     Py_END_ALLOW_THREADS
     if (!xsval) {
-        PyErr_SetFromErrno(PyExc_RuntimeError);
-        goto exit;
+        if (errno == ENOENT) {
+            Py_INCREF(Py_None);
+            val = Py_None;
+        } else
+            PyErr_SetFromErrno(PyExc_RuntimeError);
+       goto exit;
     }
     val = PyList_New(xsval_n);
     for (i = 0; i < xsval_n; i++)
         PyList_SetItem(val, i, PyString_FromString(xsval[i]));
+    free(xsval);
  exit:
     return val;
 }

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Change read and list to return None if key/dir doesn't exist., Xen patchbot -unstable <=