From: Uwe Hermann Date: Wed, 29 Feb 2012 20:56:24 +0000 (+0100) Subject: sr/srd: Consistency fixes for callbacks. X-Git-Tag: libsigrok-0.1.0~72 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d08490aabaa66b547c8299b757f62ff5319dbf0b;p=libsigrok.git sr/srd: Consistency fixes for callbacks. - Callback function pointer typedefs end with _t. - Variables holding callback functions are named 'cb' everywhere. --- diff --git a/hwdriver.c b/hwdriver.c index 9b0df152..cfd4bc32 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -315,7 +315,7 @@ SR_PRIV void sr_source_remove(int fd) } SR_PRIV void sr_source_add(int fd, int events, int timeout, - sr_receive_data_callback rcv_cb, void *user_data) + sr_receive_data_callback_t cb, void *user_data) { - sr_session_source_add(fd, events, timeout, rcv_cb, user_data); + sr_session_source_add(fd, events, timeout, cb, user_data); } diff --git a/session.c b/session.c index 5f31597e..f7af9f88 100644 --- a/session.c +++ b/session.c @@ -32,7 +32,7 @@ struct source { int fd; int events; int timeout; - sr_receive_data_callback cb; + sr_receive_data_callback_t cb; void *user_data; }; @@ -174,21 +174,21 @@ SR_API int sr_session_datafeed_callback_clear(void) /** * Add a datafeed callback to the current session. * - * @param callback Function to call when a chunk of data is received. + * @param cb Function to call when a chunk of data is received. * * @return SR_OK upon success, SR_ERR_BUG if no session exists. */ -SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback) +SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb) { if (!session) { sr_err("session: %s: session was NULL", __func__); return SR_ERR_BUG; } - /* TODO: Is 'callback' allowed to be NULL? */ + /* TODO: Is 'cb' allowed to be NULL? */ session->datafeed_callbacks = - g_slist_append(session->datafeed_callbacks, callback); + g_slist_append(session->datafeed_callbacks, cb); return SR_OK; } @@ -427,7 +427,7 @@ SR_PRIV int sr_session_bus(struct sr_dev *dev, struct sr_datafeed_packet *packet) { GSList *l; - sr_datafeed_callback cb; + sr_datafeed_callback_t cb; if (!dev) { sr_err("session: %s: dev was NULL", __func__); @@ -463,19 +463,19 @@ SR_PRIV int sr_session_bus(struct sr_dev *dev, * @param fd TODO. * @param events TODO. * @param timeout TODO. - * @param callback TODO. + * @param cb TODO. * @param user_data TODO. * * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments, or * SR_ERR_MALLOC upon memory allocation errors. */ SR_API int sr_session_source_add(int fd, int events, int timeout, - sr_receive_data_callback callback, void *user_data) + sr_receive_data_callback_t cb, void *user_data) { struct source *new_sources, *s; - if (!callback) { - sr_err("session: %s: callback was NULL", __func__); + if (!cb) { + sr_err("session: %s: cb was NULL", __func__); return SR_ERR_ARG; } @@ -497,7 +497,7 @@ SR_API int sr_session_source_add(int fd, int events, int timeout, s->fd = fd; s->events = events; s->timeout = timeout; - s->cb = callback; + s->cb = cb; s->user_data = user_data; sources = new_sources; diff --git a/sigrok-internal.h b/sigrok-internal.h index 0bc941fd..07501266 100644 --- a/sigrok-internal.h +++ b/sigrok-internal.h @@ -93,7 +93,7 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi); SR_PRIV void sr_source_remove(int fd); SR_PRIV void sr_source_add(int fd, int events, int timeout, - sr_receive_data_callback rcv_cb, void *user_data); + sr_receive_data_callback_t cb, void *user_data); /*--- hardware/common/serial.c ----------------------------------------------*/ diff --git a/sigrok-proto.h b/sigrok-proto.h index 6083b765..9bf23a52 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -78,8 +78,8 @@ SR_API struct sr_hwcap_option *sr_hw_hwcap_get(int hwcap); /*--- session.c -------------------------------------------------------------*/ -typedef void (*sr_datafeed_callback)(struct sr_dev *dev, - struct sr_datafeed_packet *packet); +typedef void (*sr_datafeed_callback_t)(struct sr_dev *dev, + struct sr_datafeed_packet *packet); /* Session setup */ SR_API int sr_session_load(const char *filename); @@ -90,7 +90,7 @@ SR_API int sr_session_dev_add(struct sr_dev *dev); /* Datafeed setup */ SR_API int sr_session_datafeed_callback_clear(void); -SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback callback); +SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb); /* Session control */ SR_API int sr_session_start(void); @@ -99,7 +99,7 @@ SR_API int sr_session_halt(void); SR_API int sr_session_stop(void); SR_API int sr_session_save(const char *filename); SR_API int sr_session_source_add(int fd, int events, int timeout, - sr_receive_data_callback callback, void *user_data); + sr_receive_data_callback_t cb, void *user_data); SR_API int sr_session_source_remove(int fd); /*--- input/input.c ---------------------------------------------------------*/ diff --git a/sigrok.h b/sigrok.h index 5bab6adf..526c0876 100644 --- a/sigrok.h +++ b/sigrok.h @@ -92,7 +92,7 @@ extern "C" { /* Marks private, non-public libsigrok symbols (not part of the API). */ #define SR_PRIV __attribute__((visibility("hidden"))) -typedef int (*sr_receive_data_callback) (int fd, int revents, void *user_data); +typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *user_data); /* Data types used by hardware drivers for dev_config_set() */ enum { @@ -360,7 +360,7 @@ struct sr_dev_driver { struct sr_session { /* List of struct sr_dev* */ GSList *devs; - /* list of sr_receive_data_callback */ + /* list of sr_receive_data_callback_t */ GSList *datafeed_callbacks; GTimeVal starttime; gboolean running;