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-3.0.4-testing] Fix the error handling in acm.policy

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.0.4-testing] Fix the error handling in acm.policy.
From: "Xen patchbot-3.0.4-testing" <patchbot-3.0.4-testing@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 03 Jan 2007 14:15:47 -0800
Delivery-date: Wed, 03 Jan 2007 14:17:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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 Ewan Mellor <ewan@xxxxxxxxxxxxx>
# Date 1167744755 0
# Node ID c309f86fde0e3a4dfd5fda745a02e592e6c85560
# Parent  d474fa3a08110fba65dc1401927601ee53627207
Fix the error handling in acm.policy.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

Based on xen-unstable changeset 13202:abcd545e7f4c0097c91f3b8f6fd046df6680bb93
---
 tools/python/xen/lowlevel/acm/acm.c |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff -r d474fa3a0811 -r c309f86fde0e tools/python/xen/lowlevel/acm/acm.c
--- a/tools/python/xen/lowlevel/acm/acm.c       Tue Jan 02 10:57:50 2007 +0000
+++ b/tools/python/xen/lowlevel/acm/acm.c       Tue Jan 02 13:32:35 2007 +0000
@@ -35,6 +35,8 @@ fprintf(stderr, "ERROR: " _m " (%d = %s)
 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a ,    \
     errno, strerror(errno))
 
+static PyObject *acm_error_obj;
+
 /* generic shared function */
 void * __getssid(int domid, uint32_t *buflen)
 {
@@ -80,28 +82,26 @@ static PyObject *policy(PyObject * self,
 {
     /* out */
     char *policyreference;
-    PyObject *ret = NULL;
+    PyObject *ret;
     void *ssid_buffer;
     uint32_t buf_len;
 
     if (!PyArg_ParseTuple(args, "", NULL)) {
-    goto out1;
+        return NULL;
     }
     ssid_buffer =  __getssid(0, &buf_len);
-    if (ssid_buffer == NULL) {
-        goto out1;
-    } else if (buf_len < sizeof(struct acm_ssid_buffer)) {
-        goto out2;
-    } else {
+    if (ssid_buffer == NULL || buf_len < sizeof(struct acm_ssid_buffer)) {
+        free(ssid_buffer);
+        return PyErr_SetFromErrno(acm_error_obj);
+    }
+    else {
         struct acm_ssid_buffer *ssid = (struct acm_ssid_buffer *)ssid_buffer;
         policyreference = (char *)(ssid_buffer + ssid->policy_reference_offset
                        + sizeof (struct acm_policy_reference_buffer));
-    }
-    ret = Py_BuildValue("s", policyreference);
- out2:
-    free(ssid_buffer);
- out1:
-    return ret;
+        ret = Py_BuildValue("s", policyreference);
+        free(ssid_buffer);
+        return ret;
+    }
 }
 
 
@@ -213,5 +213,8 @@ static PyMethodDef acmMethods[] = {
 /* inits */
 PyMODINIT_FUNC initacm(void)
 {
-    Py_InitModule("acm", acmMethods);
-}
+    PyObject *m = Py_InitModule("acm", acmMethods);
+    acm_error_obj = PyErr_NewException("acm.Error", PyExc_RuntimeError, NULL);
+    Py_INCREF(acm_error_obj);
+    PyModule_AddObject(m, "Error", acm_error_obj);
+}

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.0.4-testing] Fix the error handling in acm.policy., Xen patchbot-3.0.4-testing <=