[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Fix and cleanup error handling.



# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 639a36483fee81b15a326e3c1be8d1c2d65486de
# Parent  e991ec23c3181136bb78b761053a0a6ea641eac1
Fix and cleanup error handling.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r e991ec23c318 -r 639a36483fee tools/python/xen/lowlevel/xs/xs.c
--- a/tools/python/xen/lowlevel/xs/xs.c Wed Sep  7 12:49:52 2005
+++ b/tools/python/xen/lowlevel/xs/xs.c Wed Sep  7 13:40:06 2005
@@ -353,7 +353,7 @@
        " path     [string] : xenstore path.\n"                         \
        " token    [string] : returned in watch notification.\n"        \
        "\n"                                                            \
-       "Returns: [int] 0 on success.\n"                                \
+       "Returns None on success.\n"                                    \
        "Raises RuntimeError on error.\n"                               \
        "\n"
 
@@ -382,18 +382,22 @@
     Py_INCREF(token);
     sprintf(token_str, "%li", (unsigned long)token);
     xsval = xs_watch(xh, path, token_str);
-    val = pyvalue_int(xsval);
-    if (xsval) {
-       for (i = 0; i < PyList_Size(xsh->watches); i++) {
-           if (PyList_GetItem(xsh->watches, i) == Py_None) {
-               PyList_SetItem(xsh->watches, i, token);
-               break;
-           }
+    if (!xsval) {
+       val = PyErr_SetFromErrno(PyExc_RuntimeError);
+       Py_DECREF(token);
+       goto exit;
+    }
+
+    for (i = 0; i < PyList_Size(xsh->watches); i++) {
+       if (PyList_GetItem(xsh->watches, i) == Py_None) {
+           PyList_SetItem(xsh->watches, i, token);
+           break;
        }
-       if (i == PyList_Size(xsh->watches))
-           PyList_Append(xsh->watches, token);
-    } else
-       Py_DECREF(token);
+    }
+    if (i == PyList_Size(xsh->watches))
+       PyList_Append(xsh->watches, token);
+    Py_INCREF(Py_None);
+    val = Py_None;
  exit:
     return val;
 }
@@ -454,7 +458,7 @@
        "Acknowledge a watch notification that has been read.\n"        \
        " token [string] : from the watch notification\n"               \
        "\n"                                                            \
-       "Returns: [int] 0 on success.\n"                                \
+       "Returns None on success.\n"                                    \
        "Raises RuntimeError on error.\n"                               \
        "\n"
 
@@ -476,7 +480,12 @@
         goto exit;
     sprintf(token_str, "%li", (unsigned long)token);
     xsval = xs_acknowledge_watch(xh, token_str);
-    val = pyvalue_int(xsval);
+    if (!xsval) {
+       val = PyErr_SetFromErrno(PyExc_RuntimeError);
+       goto exit;
+    }
+    Py_INCREF(Py_None);
+    val = Py_None;
  exit:
     return val;
 }
@@ -486,7 +495,7 @@
        " path  [string] : xenstore path.\n"            \
        " token [string] : token from the watch.\n"     \
        "\n"                                            \
-       "Returns: [int] 0 on success.\n"                \
+       "Returns None on success.\n"                    \
        "Raises RuntimeError on error.\n"               \
        "\n"
 
@@ -511,7 +520,12 @@
         goto exit;
     sprintf(token_str, "%li", (unsigned long)token);
     xsval = xs_unwatch(xh, path, token_str);
-    val = pyvalue_int(xsval);
+    if (!xsval)
+       val = PyErr_SetFromErrno(PyExc_RuntimeError);
+    else {
+       Py_INCREF(Py_None);
+       val = Py_None;
+    }
     for (i = 0; i < PyList_Size(xsh->watches); i++) {
        if (token == PyList_GetItem(xsh->watches, i)) {
            Py_INCREF(Py_None);

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.