summaryrefslogtreecommitdiffstats
path: root/pywrap/pcipywrap.c
diff options
context:
space:
mode:
Diffstat (limited to 'pywrap/pcipywrap.c')
-rw-r--r--pywrap/pcipywrap.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/pywrap/pcipywrap.c b/pywrap/pcipywrap.c
index ceb0835..391bdf4 100644
--- a/pywrap/pcipywrap.c
+++ b/pywrap/pcipywrap.c
@@ -458,17 +458,22 @@ PyObject* Pcipywrap_set_property(Pcipywrap *self, PyObject* val, const char *pro
PyObject* Pcipywrap_get_registers_list(Pcipywrap *self, const char *bank)
{
- pcilib_register_info_t *list = pcilib_get_register_list(self->ctx, bank, PCILIB_LIST_FLAGS_DEFAULT);
- PyObject* pyList = PyList_New(0);
- for(int i = 0; i < ((pcilib_t*)self->ctx)->num_reg; i++)
- {
- //serialize item attributes
- PyObject* pylistItem = pcilib_convert_register_info_to_pyobject(self->ctx, list[i]);
- pcilib_pylist_append(pyList, pylistItem);
- //Py_DECREF(pylistItem);
- }
- pcilib_free_register_info(self->ctx, list);
- return pyList;
+ pcilib_register_info_t *list = pcilib_get_register_list(self->ctx, bank, PCILIB_LIST_FLAGS_DEFAULT);
+
+ if(!list) {
+ set_python_exception("pcilib_get_register_list return NULL");
+ return NULL;
+ }
+
+ PyObject* pyList = PyList_New(0);
+ for(int i = 0; list[i].name; i++)
+ {
+ //serialize item attributes
+ PyObject* pylistItem = pcilib_convert_register_info_to_pyobject(self->ctx, list[i]);
+ pcilib_pylist_append(pyList, pylistItem);
+ }
+ pcilib_free_register_info(self->ctx, list);
+ return pyList;
}
PyObject* Pcipywrap_get_register_info(Pcipywrap *self, const char* reg,const char *bank)