summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUwe Hermann <uwe@hermann-uwe.de>2018-05-18 00:01:05 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-05-18 00:01:05 +0200
commit7969d8035530d40753c4f880c90a4e90f9679ccc (patch)
treeb749d364c36c1dd457e1869508c3cea8792ae002
parent4e7ccaf9f133106786fd85a432ae23e11d9dcea2 (diff)
downloadlibsigrokdecode-7969d8035530d40753c4f880c90a4e90f9679ccc.tar.gz
libsigrokdecode-7969d8035530d40753c4f880c90a4e90f9679ccc.zip
Random whitespace/cosmetic/consistency fixes.
-rw-r--r--decoder.c38
-rw-r--r--exception.c2
-rw-r--r--instance.c15
-rw-r--r--module_sigrokdecode.c2
-rw-r--r--session.c3
-rw-r--r--srd.c4
-rw-r--r--type_decoder.c30
-rw-r--r--util.c3
8 files changed, 51 insertions, 46 deletions
diff --git a/decoder.c b/decoder.c
index 87df2ad..c195e4b 100644
--- a/decoder.c
+++ b/decoder.c
@@ -243,6 +243,7 @@ static int get_channels(const struct srd_decoder *d, const char *attr,
except_out:
srd_exception_catch("Failed to get %s list of %s decoder",
attr, d->name);
+
err_out:
g_slist_free_full(pdchl, &channel_free);
Py_XDECREF(py_channellist);
@@ -324,8 +325,10 @@ static int get_options(struct srd_decoder *d)
py_values = PyDict_GetItemString(py_opt, "values");
if (py_values) {
- /* A default is required if a list of values is
- * given, since it's used to verify their type. */
+ /*
+ * A default is required if a list of values is
+ * given, since it's used to verify their type.
+ */
if (!o->def) {
srd_err("No default for option '%s'.", o->id);
goto err_out;
@@ -365,6 +368,7 @@ static int get_options(struct srd_decoder *d)
except_out:
srd_exception_catch("Failed to get %s decoder options", d->name);
+
err_out:
g_slist_free_full(options, &decoder_option_free);
Py_XDECREF(py_opts);
@@ -373,8 +377,7 @@ err_out:
return SRD_ERR_PYTHON;
}
-/* Convert annotation class attribute to GSList of char **.
- */
+/* Convert annotation class attribute to GSList of char **. */
static int get_annotations(struct srd_decoder *dec)
{
PyObject *py_annlist, *py_ann;
@@ -426,6 +429,7 @@ static int get_annotations(struct srd_decoder *dec)
except_out:
srd_exception_catch("Failed to get %s decoder annotations", dec->name);
+
err_out:
g_slist_free_full(annotations, (GDestroyNotify)&g_strfreev);
Py_XDECREF(py_annlist);
@@ -434,8 +438,7 @@ err_out:
return SRD_ERR_PYTHON;
}
-/* Convert annotation_rows to GSList of 'struct srd_decoder_annotation_row'.
- */
+/* Convert annotation_rows to GSList of 'struct srd_decoder_annotation_row'. */
static int get_annotation_rows(struct srd_decoder *dec)
{
PyObject *py_ann_rows, *py_ann_row, *py_ann_classes, *py_item;
@@ -530,6 +533,7 @@ static int get_annotation_rows(struct srd_decoder *dec)
except_out:
srd_exception_catch("Failed to get %s decoder annotation rows",
dec->name);
+
err_out:
g_slist_free_full(annotation_rows, &annotation_row_free);
Py_XDECREF(py_ann_rows);
@@ -538,8 +542,7 @@ err_out:
return SRD_ERR_PYTHON;
}
-/* Convert binary classes to GSList of char **.
- */
+/* Convert binary classes to GSList of char **. */
static int get_binary_classes(struct srd_decoder *dec)
{
PyObject *py_bin_classes, *py_bin_class;
@@ -593,6 +596,7 @@ static int get_binary_classes(struct srd_decoder *dec)
except_out:
srd_exception_catch("Failed to get %s decoder binary classes",
dec->name);
+
err_out:
g_slist_free_full(bin_classes, (GDestroyNotify)&g_strfreev);
Py_XDECREF(py_bin_classes);
@@ -601,8 +605,7 @@ err_out:
return SRD_ERR_PYTHON;
}
-/* Check whether the Decoder class defines the named method.
- */
+/* Check whether the Decoder class defines the named method. */
static int check_method(PyObject *py_dec, const char *mod_name,
const char *method_name)
{
@@ -746,8 +749,8 @@ SRD_API int srd_decoder_load(const char *module_name)
goto err_out;
}
- /* Check Decoder class for required methods.
- */
+ /* Check Decoder class for required methods. */
+
if (check_method(d->py_dec, module_name, "start") != SRD_OK) {
fail_txt = "no 'start()' method";
goto err_out;
@@ -842,6 +845,7 @@ except_out:
module_name, fail_txt);
}
fail_txt = NULL;
+
err_out:
if (fail_txt)
srd_err("Failed to load decoder %s: %s", module_name, fail_txt);
@@ -1027,21 +1031,21 @@ static void srd_decoder_load_all_path(char *path)
const gchar *direntry;
if (!(dir = g_dir_open(path, 0, NULL))) {
- /* Not really fatal */
- /* Try zipimport method too */
+ /* Not really fatal. Try zipimport method too. */
srd_decoder_load_all_zip_path(path);
return;
}
- /* This ignores errors returned by srd_decoder_load(). That
+ /*
+ * This ignores errors returned by srd_decoder_load(). That
* function will have logged the cause, but in any case we
- * want to continue anyway. */
+ * want to continue anyway.
+ */
while ((direntry = g_dir_read_name(dir)) != NULL) {
/* The directory name is the module name (e.g. "i2c"). */
srd_decoder_load(direntry);
}
g_dir_close(dir);
-
}
/**
diff --git a/exception.c b/exception.c
index 8b50883..9f8ee4c 100644
--- a/exception.c
+++ b/exception.c
@@ -50,6 +50,7 @@ cleanup:
PyErr_Clear();
srd_dbg("Failed to stringify object.");
}
+
return str;
}
@@ -80,6 +81,7 @@ cleanup:
PyErr_Clear();
srd_dbg("Failed to get object attribute %s.", attr);
}
+
return str;
}
diff --git a/instance.c b/instance.c
index 8d660a4..c28ede9 100644
--- a/instance.c
+++ b/instance.c
@@ -177,7 +177,7 @@ err_out:
return ret;
}
-/* Helper GComparefunc for g_slist_find_custom() in srd_inst_channel_set_all() */
+/* Helper GComparefunc for g_slist_find_custom() in srd_inst_channel_set_all(). */
static gint compare_channel_id(const struct srd_channel *pdch,
const char *channel_id)
{
@@ -460,9 +460,7 @@ static void srd_inst_reset_state(struct srd_decoder_inst *di)
srd_dbg("%s: Resetting decoder state.", di->inst_id);
- /*
- * Reset internal state of the decoder.
- */
+ /* Reset internal state of the decoder. */
condition_list_free(di);
match_array_free(di);
di->abs_start_samplenum = 0;
@@ -1269,6 +1267,7 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di,
if (di->want_wait_terminate)
return SRD_ERR_TERM_REQ;
+
return SRD_OK;
}
@@ -1285,7 +1284,9 @@ SRD_PRIV int srd_inst_decode(struct srd_decoder_inst *di,
* calls like they would for newly constructed decoder stacks.
*
* @param di The decoder instance to call. Must not be NULL.
+ *
* @return SRD_OK upon success, a (negative) error code otherwise.
+ *
* @private
*/
SRD_PRIV int srd_inst_terminate_reset(struct srd_decoder_inst *di)
@@ -1324,9 +1325,7 @@ SRD_PRIV int srd_inst_terminate_reset(struct srd_decoder_inst *di)
}
PyGILState_Release(gstate);
- /*
- * Pass the "restart" request to all stacked decoders.
- */
+ /* Pass the "restart" request to all stacked decoders. */
for (l = di->next_di; l; l = l->next) {
ret = srd_inst_terminate_reset(l->data);
if (ret != SRD_OK)
@@ -1343,7 +1342,7 @@ SRD_PRIV void srd_inst_free(struct srd_decoder_inst *di)
struct srd_pd_output *pdo;
PyGILState_STATE gstate;
- srd_dbg("Freeing instance %s", di->inst_id);
+ srd_dbg("Freeing instance %s.", di->inst_id);
srd_inst_join_decode_thread(di);
diff --git a/module_sigrokdecode.c b/module_sigrokdecode.c
index ab5df19..39b5b43 100644
--- a/module_sigrokdecode.c
+++ b/module_sigrokdecode.c
@@ -74,6 +74,7 @@ PyMODINIT_FUNC PyInit_sigrokdecode(void)
PyGILState_Release(gstate);
return mod;
+
err_out:
Py_XDECREF(mod);
srd_exception_catch("Failed to initialize module");
@@ -81,4 +82,5 @@ err_out:
return NULL;
}
+
/** @endcond */
diff --git a/session.c b/session.c
index 4d794df..cec97cf 100644
--- a/session.c
+++ b/session.c
@@ -48,7 +48,6 @@ SRD_PRIV int max_session_id = -1;
/** @private */
SRD_PRIV int session_is_valid(struct srd_session *sess)
{
-
if (!sess || sess->session_id < 1)
return SRD_ERR;
@@ -70,7 +69,6 @@ SRD_PRIV int session_is_valid(struct srd_session *sess)
*/
SRD_API int srd_session_new(struct srd_session **sess)
{
-
if (!sess) {
srd_err("Invalid session pointer.");
return SRD_ERR_ARG;
@@ -333,6 +331,7 @@ SRD_API int srd_session_terminate_reset(struct srd_session *sess)
if (ret != SRD_OK)
return ret;
}
+
return SRD_OK;
}
diff --git a/srd.c b/srd.c
index bed8031..e040e3a 100644
--- a/srd.c
+++ b/srd.c
@@ -105,7 +105,7 @@ static int searchpath_add_xdg_dir(const char *datadir)
if (g_file_test(decdir, G_FILE_TEST_IS_DIR))
ret = srd_decoder_searchpath_add(decdir);
else
- ret = SRD_OK; /* just ignore non-existing directory */
+ ret = SRD_OK; /* Just ignore non-existing directory. */
g_free(decdir);
@@ -245,7 +245,7 @@ SRD_API int srd_init(const char *path)
/* Locations relative to the XDG system data directories. */
sys_datadirs = g_get_system_data_dirs();
for (i = g_strv_length((char **)sys_datadirs); i > 0; i--) {
- ret = searchpath_add_xdg_dir(sys_datadirs[i-1]);
+ ret = searchpath_add_xdg_dir(sys_datadirs[i - 1]);
if (ret != SRD_OK) {
Py_Finalize();
return ret;
diff --git a/type_decoder.c b/type_decoder.c
index e69b3c4..2f15ee6 100644
--- a/type_decoder.c
+++ b/type_decoder.c
@@ -26,8 +26,7 @@ typedef struct {
PyObject_HEAD
} srd_Decoder;
-/* This is only used for nicer srd_dbg() output.
- */
+/* This is only used for nicer srd_dbg() output. */
static const char *output_type_name(unsigned int idx)
{
static const char names[][16] = {
@@ -37,6 +36,7 @@ static const char *output_type_name(unsigned int idx)
"OUTPUT_META",
"(invalid)"
};
+
return names[MIN(idx, G_N_ELEMENTS(names) - 1)];
}
@@ -332,8 +332,10 @@ static PyObject *Decoder_put(PyObject *self, PyObject *args)
Py_XDECREF(py_res);
}
if ((cb = srd_pd_output_callback_find(di->sess, pdo->output_type))) {
- /* Frontends aren't really supposed to get Python
- * callbacks, but it's useful for testing. */
+ /*
+ * Frontends aren't really supposed to get Python
+ * callbacks, but it's useful for testing.
+ */
pdata.data = py_data;
cb->cb(&pdata, cb->cb_data);
}
@@ -390,7 +392,7 @@ static PyObject *Decoder_register(PyObject *self, PyObject *args,
const GVariantType *meta_type_gv;
int output_type;
char *proto_id, *meta_name, *meta_descr;
- char *keywords[] = {"output_type", "proto_id", "meta", NULL};
+ char *keywords[] = { "output_type", "proto_id", "meta", NULL };
PyGILState_STATE gstate;
gboolean is_meta;
GSList *l;
@@ -407,7 +409,7 @@ static PyObject *Decoder_register(PyObject *self, PyObject *args,
goto err;
}
- /* Default to instance id, which defaults to class id. */
+ /* Default to instance ID, which defaults to class ID. */
proto_id = di->inst_id;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i|s(Oss)", keywords,
&output_type, &proto_id,
@@ -957,14 +959,14 @@ err:
}
static PyMethodDef Decoder_methods[] = {
- {"put", Decoder_put, METH_VARARGS,
- "Accepts a dictionary with the following keys: startsample, endsample, data"},
- {"register", (PyCFunction)Decoder_register, METH_VARARGS|METH_KEYWORDS,
- "Register a new output stream"},
- {"wait", Decoder_wait, METH_VARARGS,
- "Wait for one or more conditions to occur"},
- {"has_channel", Decoder_has_channel, METH_VARARGS,
- "Report whether a channel was supplied"},
+ { "put", Decoder_put, METH_VARARGS,
+ "Accepts a dictionary with the following keys: startsample, endsample, data" },
+ { "register", (PyCFunction)Decoder_register, METH_VARARGS|METH_KEYWORDS,
+ "Register a new output stream" },
+ { "wait", Decoder_wait, METH_VARARGS,
+ "Wait for one or more conditions to occur" },
+ { "has_channel", Decoder_has_channel, METH_VARARGS,
+ "Report whether a channel was supplied" },
{NULL, NULL, 0, NULL}
};
diff --git a/util.c b/util.c
index 7c09f6d..442d0a6 100644
--- a/util.c
+++ b/util.c
@@ -490,7 +490,6 @@ SRD_PRIV GVariant *py_obj_to_variant(PyObject *py_obj)
}
if (!var)
srd_exception_catch("Failed to extract string value");
-
} else if (PyLong_Check(py_obj)) { /* integer */
int64_t val;
@@ -499,7 +498,6 @@ SRD_PRIV GVariant *py_obj_to_variant(PyObject *py_obj)
var = g_variant_new_int64(val);
else
srd_exception_catch("Failed to extract integer value");
-
} else if (PyFloat_Check(py_obj)) { /* float */
double val;
@@ -508,7 +506,6 @@ SRD_PRIV GVariant *py_obj_to_variant(PyObject *py_obj)
var = g_variant_new_double(val);
else
srd_exception_catch("Failed to extract float value");
-
} else {
srd_err("Failed to extract value of unsupported type.");
}