direct-io.hg

changeset 1435:79da98e3f9aa

bitkeeper revision 1.938 (40c09a9eB7glN2Y8gzy_3h0d_Hcv-A)

Small cleanups.
author kaf24@scramble.cl.cam.ac.uk
date Fri Jun 04 15:51:58 2004 +0000 (2004-06-04)
parents 833ef5f19355
children 64c28f73f702
files tools/xend/lib/utils.c
line diff
     1.1 --- a/tools/xend/lib/utils.c	Fri Jun 04 15:22:06 2004 +0000
     1.2 +++ b/tools/xend/lib/utils.c	Fri Jun 04 15:51:58 2004 +0000
     1.3 @@ -249,6 +249,7 @@ static PyTypeObject xu_notifier_type = {
     1.4      do {                                                                  \
     1.5          PyObject *obj = Py ## _pytype ## _From ## _ctype1                 \
     1.6                          (((_struct *)&xum->msg.msg[0])->_field);          \
     1.7 +        if ( dict == NULL ) dict = PyDict_New();                          \
     1.8          PyDict_SetItemString(dict, #_field, obj);                         \
     1.9      } while ( 0 )
    1.10  
    1.11 @@ -304,13 +305,11 @@ static PyObject *xu_message_set_response
    1.12  static PyObject *xu_message_get_payload(PyObject *self, PyObject *args)
    1.13  {
    1.14      xu_message_object *xum = (xu_message_object *)self;
    1.15 -    PyObject *dict;
    1.16 +    PyObject *dict = NULL;
    1.17  
    1.18      if ( !PyArg_ParseTuple(args, "") )
    1.19          return NULL;
    1.20  
    1.21 -    dict = PyDict_New();
    1.22 -
    1.23      switch ( TYPE(xum->msg.type, xum->msg.subtype) )
    1.24      {
    1.25      case TYPE(CMSG_BLKIF_FE, CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED):
    1.26 @@ -428,35 +427,9 @@ static PyObject *xu_message_get_payload(
    1.27          return dict;
    1.28      }
    1.29  
    1.30 -    PyObject_Del(dict); /* didn't use it after all */
    1.31 -
    1.32      return PyString_FromStringAndSize(xum->msg.msg, xum->msg.length);
    1.33  }
    1.34  
    1.35 -static PyObject *xu_message_set_header(PyObject *self, 
    1.36 -                                       PyObject *args, 
    1.37 -                                       PyObject *kwds)
    1.38 -{
    1.39 -    xu_message_object *xum = (xu_message_object *)self;
    1.40 -    int type = -1, subtype = -1, id = -1;
    1.41 -
    1.42 -    static char *kwd_list[] = { "type", "subtype", "id", NULL };
    1.43 -
    1.44 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|iii", kwd_list,
    1.45 -                                      &type, &subtype, &id) )
    1.46 -        return NULL;
    1.47 -
    1.48 -    if ( type != -1 )
    1.49 -        xum->msg.type = (u8)type;
    1.50 -    if ( subtype != -1 )
    1.51 -        xum->msg.subtype = (u8)subtype;
    1.52 -    if ( id != -1 )
    1.53 -        xum->msg.id = (u8)id;
    1.54 -
    1.55 -    Py_INCREF(Py_None);
    1.56 -    return Py_None;
    1.57 -}
    1.58 -
    1.59  static PyObject *xu_message_get_header(PyObject *self, PyObject *args)
    1.60  {
    1.61      xu_message_object *xum = (xu_message_object *)self;
    1.62 @@ -486,11 +459,6 @@ static PyMethodDef xu_message_methods[] 
    1.63        METH_VARARGS,
    1.64        "Return the message payload in string form.\n" },
    1.65  
    1.66 -    { "set_header",
    1.67 -      (PyCFunction)xu_message_set_header,
    1.68 -      METH_VARARGS | METH_KEYWORDS,
    1.69 -      "Accepts keywords @type, @subtype, and @id.\n" },
    1.70 -
    1.71      { "get_header",
    1.72        (PyCFunction)xu_message_get_header,
    1.73        METH_VARARGS,
    1.74 @@ -523,7 +491,8 @@ static PyObject *xu_message_new(PyObject
    1.75      if ( !PyDict_Check(payload) )
    1.76      {
    1.77          PyErr_SetString(PyExc_TypeError, "payload is not a dictionary");
    1.78 -        goto fail;
    1.79 +        PyObject_Del((PyObject *)xum);
    1.80 +        return NULL;
    1.81      }
    1.82  
    1.83      switch ( TYPE(type, subtype) )
    1.84 @@ -617,10 +586,6 @@ static PyObject *xu_message_new(PyObject
    1.85      }
    1.86  
    1.87      return (PyObject *)xum;
    1.88 -
    1.89 - fail:
    1.90 -    PyObject_Del((PyObject *)xum);
    1.91 -    return NULL;
    1.92  }
    1.93  
    1.94  static PyObject *xu_message_getattr(PyObject *obj, char *name)