debuggers.hg
changeset 6696:639a36483fee
Fix and cleanup error handling.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author | cl349@firebug.cl.cam.ac.uk |
---|---|
date | Wed Sep 07 13:40:06 2005 +0000 (2005-09-07) |
parents | e991ec23c318 |
children | c9e1ddf85324 |
files | tools/python/xen/lowlevel/xs/xs.c |
line diff
1.1 --- a/tools/python/xen/lowlevel/xs/xs.c Wed Sep 07 12:49:52 2005 +0000 1.2 +++ b/tools/python/xen/lowlevel/xs/xs.c Wed Sep 07 13:40:06 2005 +0000 1.3 @@ -353,7 +353,7 @@ static PyObject *xspy_set_permissions(Py 1.4 " path [string] : xenstore path.\n" \ 1.5 " token [string] : returned in watch notification.\n" \ 1.6 "\n" \ 1.7 - "Returns: [int] 0 on success.\n" \ 1.8 + "Returns None on success.\n" \ 1.9 "Raises RuntimeError on error.\n" \ 1.10 "\n" 1.11 1.12 @@ -382,18 +382,22 @@ static PyObject *xspy_watch(PyObject *se 1.13 Py_INCREF(token); 1.14 sprintf(token_str, "%li", (unsigned long)token); 1.15 xsval = xs_watch(xh, path, token_str); 1.16 - val = pyvalue_int(xsval); 1.17 - if (xsval) { 1.18 - for (i = 0; i < PyList_Size(xsh->watches); i++) { 1.19 - if (PyList_GetItem(xsh->watches, i) == Py_None) { 1.20 - PyList_SetItem(xsh->watches, i, token); 1.21 - break; 1.22 - } 1.23 + if (!xsval) { 1.24 + val = PyErr_SetFromErrno(PyExc_RuntimeError); 1.25 + Py_DECREF(token); 1.26 + goto exit; 1.27 + } 1.28 + 1.29 + for (i = 0; i < PyList_Size(xsh->watches); i++) { 1.30 + if (PyList_GetItem(xsh->watches, i) == Py_None) { 1.31 + PyList_SetItem(xsh->watches, i, token); 1.32 + break; 1.33 } 1.34 - if (i == PyList_Size(xsh->watches)) 1.35 - PyList_Append(xsh->watches, token); 1.36 - } else 1.37 - Py_DECREF(token); 1.38 + } 1.39 + if (i == PyList_Size(xsh->watches)) 1.40 + PyList_Append(xsh->watches, token); 1.41 + Py_INCREF(Py_None); 1.42 + val = Py_None; 1.43 exit: 1.44 return val; 1.45 } 1.46 @@ -454,7 +458,7 @@ static PyObject *xspy_read_watch(PyObjec 1.47 "Acknowledge a watch notification that has been read.\n" \ 1.48 " token [string] : from the watch notification\n" \ 1.49 "\n" \ 1.50 - "Returns: [int] 0 on success.\n" \ 1.51 + "Returns None on success.\n" \ 1.52 "Raises RuntimeError on error.\n" \ 1.53 "\n" 1.54 1.55 @@ -476,7 +480,12 @@ static PyObject *xspy_acknowledge_watch( 1.56 goto exit; 1.57 sprintf(token_str, "%li", (unsigned long)token); 1.58 xsval = xs_acknowledge_watch(xh, token_str); 1.59 - val = pyvalue_int(xsval); 1.60 + if (!xsval) { 1.61 + val = PyErr_SetFromErrno(PyExc_RuntimeError); 1.62 + goto exit; 1.63 + } 1.64 + Py_INCREF(Py_None); 1.65 + val = Py_None; 1.66 exit: 1.67 return val; 1.68 } 1.69 @@ -486,7 +495,7 @@ static PyObject *xspy_acknowledge_watch( 1.70 " path [string] : xenstore path.\n" \ 1.71 " token [string] : token from the watch.\n" \ 1.72 "\n" \ 1.73 - "Returns: [int] 0 on success.\n" \ 1.74 + "Returns None on success.\n" \ 1.75 "Raises RuntimeError on error.\n" \ 1.76 "\n" 1.77 1.78 @@ -511,7 +520,12 @@ static PyObject *xspy_unwatch(PyObject * 1.79 goto exit; 1.80 sprintf(token_str, "%li", (unsigned long)token); 1.81 xsval = xs_unwatch(xh, path, token_str); 1.82 - val = pyvalue_int(xsval); 1.83 + if (!xsval) 1.84 + val = PyErr_SetFromErrno(PyExc_RuntimeError); 1.85 + else { 1.86 + Py_INCREF(Py_None); 1.87 + val = Py_None; 1.88 + } 1.89 for (i = 0; i < PyList_Size(xsh->watches); i++) { 1.90 if (token == PyList_GetItem(xsh->watches, i)) { 1.91 Py_INCREF(Py_None);