From: Bert Vermeulen Date: Sun, 8 Jan 2012 23:13:03 +0000 (+0100) Subject: code cleanup X-Git-Tag: libsigrokdecode-0.1.0~188 X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=commitdiff_plain;h=b231546d63396fd6cac381b12b99caf07687e7e3 code cleanup --- diff --git a/controller.c b/controller.c index 1ed852b..a0e8bfe 100644 --- a/controller.c +++ b/controller.c @@ -138,8 +138,6 @@ struct srd_decoder_instance *srd_instance_new(const char *id) struct srd_decoder_instance *di; PyObject *py_args; - fprintf(stdout, "%s: %s\n", __func__, id); - if (!(dec = srd_get_decoder_by_id(id))) return NULL; @@ -202,8 +200,6 @@ int srd_session_start(int num_probes, int unitsize, uint64_t samplerate) GSList *d; struct srd_decoder_instance *di; - fprintf(stdout, "%s\n", __func__); - for (d = di_list; d; d = d->next) { di = d->data; di->num_probes = num_probes; @@ -281,8 +277,6 @@ int srd_session_feed(uint64_t timeoffset, uint64_t duration, uint8_t *inbuf, GSList *d; int ret; -// fprintf(stdout, "%s: %d bytes\n", __func__, inbuflen); - for (d = di_list; d; d = d->next) { if ((ret = srd_run_decoder(timeoffset, duration, d->data, inbuf, inbuflen)) != SRD_OK) @@ -301,16 +295,13 @@ int pd_add(struct srd_decoder_instance *di, int output_type, if (!(pdo = g_try_malloc(sizeof(struct srd_pd_output)))) return -1; - /* pdo_id is just a simple index, nothing is deleted from this list anway */ + /* pdo_id is just a simple index, nothing is deleted from this list anyway. */ pdo->pdo_id = g_slist_length(di->pd_output); pdo->output_type = output_type; pdo->decoder = di->decoder; pdo->protocol_id = g_strdup(protocol_id); di->pd_output = g_slist_append(di->pd_output, pdo); - fprintf(stdout, "%s: output type %d, protocol_id %s, id %d\n", - __func__, output_type, protocol_id, pdo->pdo_id); - return pdo->pdo_id; } @@ -339,7 +330,6 @@ int srd_register_callback(int output_type, void *cb) pd_cb->callback = cb; callbacks = g_slist_append(callbacks, pd_cb); - printf("got cb for %d: %p\n", output_type, cb); return SRD_OK; } diff --git a/decoder.c b/decoder.c index f06d5e9..788d2e8 100644 --- a/decoder.c +++ b/decoder.c @@ -78,8 +78,6 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec) int alen, r, i; char **ann; - fprintf(stdout, "%s: %s\n", __func__, name); - /* "Import" the Python module. */ if (!(py_mod = PyImport_ImportModule(name))) { /* NEWREF */ PyErr_Print(); /* Returns void. */ @@ -92,7 +90,7 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec) if (PyErr_Occurred()) PyErr_Print(); /* Returns void. */ Py_XDECREF(py_mod); - fprintf(stderr, "Decoder class not found in PD module %s\n", name); + srd_err("Decoder class not found in PD module %s", name); return SRD_ERR_PYTHON; /* TODO: More specific error? */ } @@ -117,9 +115,6 @@ int srd_load_decoder(const char *name, struct srd_decoder **dec) if ((r = h_str(py_res, "author", &(d->author))) < 0) return r; - if ((r = h_str(py_res, "email", &(d->email))) < 0) - return r; - if ((r = h_str(py_res, "license", &(d->license))) < 0) return r; @@ -168,7 +163,11 @@ int srd_unload_decoder(struct srd_decoder *dec) { g_free(dec->id); g_free(dec->name); + g_free(dec->longname); g_free(dec->desc); + g_free(dec->longdesc); + g_free(dec->author); + g_free(dec->license); g_free(dec->func); /* TODO: Free everything in inputformats and outputformats. */ diff --git a/module_sigrokdecode.c b/module_sigrokdecode.c index 69bd17e..720bfd3 100644 --- a/module_sigrokdecode.c +++ b/module_sigrokdecode.c @@ -79,16 +79,6 @@ static int convert_pyobj(struct srd_decoder_instance *di, PyObject *obj, return SRD_OK; } -/* TODO: not used, doesn't work actually */ -static PyObject *Decoder_init(PyObject *self, PyObject *args) -{ - (void)self; - (void)args; - printf("init Decoder object %p\n", self); - - Py_RETURN_NONE; -} - static PyObject *Decoder_put(PyObject *self, PyObject *args) { GSList *l; @@ -158,8 +148,6 @@ static PyObject *Decoder_add(PyObject *self, PyObject *args) if (!(di = get_di_by_decobject(self))) return NULL; - printf("output_new di %s\n", di->decoder->name); - if (!PyArg_ParseTuple(args, "is", &output_type, &protocol_id)) return NULL; @@ -192,7 +180,6 @@ static PyTypeObject srd_Decoder_type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, .tp_doc = "Sigrok Decoder object", .tp_methods = Decoder_methods, - .tp_init = (initproc) Decoder_init, }; static struct PyModuleDef sigrokdecode_module = { diff --git a/sigrokdecode.h b/sigrokdecode.h index 1473969..42749d3 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -96,9 +96,6 @@ struct srd_decoder { /** The author of the decoder. May be NULL. */ char *author; - /** An email address of the decoder's author. May be NULL. */ - char *email; - /** The license of the decoder. Valid values: "gplv2+", "gplv3+". */ char *license;