From: Uwe Hermann Date: Sat, 3 May 2014 20:14:01 +0000 (+0200) Subject: Don't define names ending with _t (POSIX reserved). X-Git-Tag: libsigrok-0.3.0~16 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=144f6660d004d60264a57db7150ed90e5f68ea77;p=libsigrok.git Don't define names ending with _t (POSIX reserved). Avoid defining any names ending in _t, those are generally reserved for POSIX usage. For details see: http://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html --- diff --git a/hardware/brymen-dmm/protocol.c b/hardware/brymen-dmm/protocol.c index 664258aa..dff7b985 100644 --- a/hardware/brymen-dmm/protocol.c +++ b/hardware/brymen-dmm/protocol.c @@ -174,7 +174,7 @@ SR_PRIV int brymen_dmm_receive_data(int fd, int revents, void *cb_data) SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial, uint8_t *buf, size_t *buflen, packet_length_t get_packet_size, - packet_valid_t is_valid, + packet_valid_callback is_valid, uint64_t timeout_ms, int baudrate) { int64_t start, time, byte_delay_us; diff --git a/hardware/brymen-dmm/protocol.h b/hardware/brymen-dmm/protocol.h index 5b6f787e..7c9aaae6 100644 --- a/hardware/brymen-dmm/protocol.h +++ b/hardware/brymen-dmm/protocol.h @@ -82,7 +82,7 @@ SR_PRIV int brymen_parse(const uint8_t *buf, float *floatval, SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial, uint8_t *buf, size_t *buflen, packet_length_t get_packet_size, - packet_valid_t is_valid, + packet_valid_callback is_valid, uint64_t timeout_ms, int baudrate); #endif diff --git a/hardware/common/scpi.c b/hardware/common/scpi.c index 3d99954b..dbcd3f09 100644 --- a/hardware/common/scpi.c +++ b/hardware/common/scpi.c @@ -217,7 +217,7 @@ SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi) * SR_ERR_MALLOC upon memory allocation errors. */ SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data) + int timeout, sr_receive_data_callback cb, void *cb_data) { return scpi->source_add(scpi->priv, events, timeout, cb, cb_data); } diff --git a/hardware/common/scpi_serial.c b/hardware/common/scpi_serial.c index e0936c01..7000962a 100644 --- a/hardware/common/scpi_serial.c +++ b/hardware/common/scpi_serial.c @@ -103,7 +103,7 @@ static int scpi_serial_open(void *priv) } static int scpi_serial_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { struct scpi_serial *sscpi = priv; struct sr_serial_dev_inst *serial = sscpi->serial; diff --git a/hardware/common/scpi_tcp.c b/hardware/common/scpi_tcp.c index 21235f36..8ac2200f 100644 --- a/hardware/common/scpi_tcp.c +++ b/hardware/common/scpi_tcp.c @@ -116,7 +116,7 @@ static int scpi_tcp_open(void *priv) } static int scpi_tcp_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { struct scpi_tcp *tcp = priv; diff --git a/hardware/common/scpi_usbtmc.c b/hardware/common/scpi_usbtmc.c index 1ffc34ae..8254f801 100644 --- a/hardware/common/scpi_usbtmc.c +++ b/hardware/common/scpi_usbtmc.c @@ -87,7 +87,7 @@ static int scpi_usbtmc_open(void *priv) } static int scpi_usbtmc_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { struct usbtmc_scpi *uscpi = priv; struct sr_usbtmc_dev_inst *usbtmc = uscpi->usbtmc; diff --git a/hardware/common/scpi_usbtmc_libusb.c b/hardware/common/scpi_usbtmc_libusb.c index c814ba16..653a0d8c 100644 --- a/hardware/common/scpi_usbtmc_libusb.c +++ b/hardware/common/scpi_usbtmc_libusb.c @@ -317,7 +317,7 @@ static int scpi_usbtmc_libusb_open(void *priv) } static int scpi_usbtmc_libusb_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { struct scpi_usbtmc_libusb *uscpi = priv; (void)events; diff --git a/hardware/common/scpi_visa.c b/hardware/common/scpi_visa.c index 1db85d82..b342a91f 100644 --- a/hardware/common/scpi_visa.c +++ b/hardware/common/scpi_visa.c @@ -68,7 +68,7 @@ static int scpi_visa_open(void *priv) } static int scpi_visa_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { (void) priv; diff --git a/hardware/common/scpi_vxi.c b/hardware/common/scpi_vxi.c index 767303b5..639b3b56 100644 --- a/hardware/common/scpi_vxi.c +++ b/hardware/common/scpi_vxi.c @@ -92,7 +92,7 @@ static int scpi_vxi_open(void *priv) } static int scpi_vxi_source_add(void *priv, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { (void)priv; diff --git a/hardware/common/serial.c b/hardware/common/serial.c index 32a6d23c..e99b768b 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -570,7 +570,8 @@ SR_PRIV int serial_readline(struct sr_serial_dev_inst *serial, char **buf, */ SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, uint8_t *buf, size_t *buflen, - size_t packet_size, packet_valid_t is_valid, + size_t packet_size, + packet_valid_callback is_valid, uint64_t timeout_ms, int baudrate) { uint64_t start, time, byte_delay_us; @@ -684,7 +685,7 @@ typedef int event_handle; #endif SR_PRIV int serial_source_add(struct sr_serial_dev_inst *serial, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data) + int timeout, sr_receive_data_callback cb, void *cb_data) { enum sp_event mask = 0; unsigned int i; diff --git a/hardware/common/usb.c b/hardware/common/usb.c index a4845c93..62db385b 100644 --- a/hardware/common/usb.c +++ b/hardware/common/usb.c @@ -210,7 +210,7 @@ static int usb_callback(int fd, int revents, void *cb_data) #endif SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { if (ctx->usb_source_present) { sr_err("A USB event source is already present."); diff --git a/hwdriver.c b/hwdriver.c index f55a6790..fee0dd08 100644 --- a/hwdriver.c +++ b/hwdriver.c @@ -776,7 +776,7 @@ SR_PRIV int sr_source_remove(int fd) * @see sr_session_source_add() */ SR_PRIV int sr_source_add(int fd, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { return sr_session_source_add(fd, events, timeout, cb, cb_data); } diff --git a/libsigrok-internal.h b/libsigrok-internal.h index 89bedde1..eb4b1a2c 100644 --- a/libsigrok-internal.h +++ b/libsigrok-internal.h @@ -153,7 +153,7 @@ struct sr_context { GMutex usb_mutex; HANDLE usb_event; GPollFD usb_pollfd; - sr_receive_data_callback_t usb_cb; + sr_receive_data_callback usb_cb; void *usb_cb_data; #endif #endif @@ -265,7 +265,7 @@ SR_PRIV struct sr_config *sr_config_new(int key, GVariant *data); SR_PRIV void sr_config_free(struct sr_config *src); SR_PRIV int sr_source_remove(int fd); SR_PRIV int sr_source_add(int fd, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data); + sr_receive_data_callback cb, void *cb_data); /*--- session.c -------------------------------------------------------------*/ @@ -307,21 +307,21 @@ SR_PRIV int sr_sessionfile_check(const char *filename); /*--- std.c -----------------------------------------------------------------*/ -typedef int (*dev_close_t)(struct sr_dev_inst *sdi); -typedef void (*std_dev_clear_t)(void *priv); +typedef int (*dev_close_callback)(struct sr_dev_inst *sdi); +typedef void (*std_dev_clear_callback)(void *priv); SR_PRIV int std_init(struct sr_context *sr_ctx, struct sr_dev_driver *di, const char *prefix); #ifdef HAVE_LIBSERIALPORT SR_PRIV int std_serial_dev_open(struct sr_dev_inst *sdi); SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi, - void *cb_data, dev_close_t dev_close_fn, + void *cb_data, dev_close_callback dev_close_fn, struct sr_serial_dev_inst *serial, const char *prefix); #endif SR_PRIV int std_session_send_df_header(const struct sr_dev_inst *sdi, const char *prefix); SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, - std_dev_clear_t clear_private); + std_dev_clear_callback clear_private); SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi); /*--- strutil.c -------------------------------------------------------------*/ @@ -341,7 +341,7 @@ enum { SERIAL_NONBLOCK = 4, }; -typedef gboolean (*packet_valid_t)(const uint8_t *buf); +typedef gboolean (*packet_valid_callback)(const uint8_t *buf); SR_PRIV int serial_open(struct sr_serial_dev_inst *serial, int flags); SR_PRIV int serial_close(struct sr_serial_dev_inst *serial); @@ -366,12 +366,13 @@ SR_PRIV int serial_readline(struct sr_serial_dev_inst *serial, char **buf, int *buflen, gint64 timeout_ms); SR_PRIV int serial_stream_detect(struct sr_serial_dev_inst *serial, uint8_t *buf, size_t *buflen, - size_t packet_size, packet_valid_t is_valid, + size_t packet_size, + packet_valid_callback is_valid, uint64_t timeout_ms, int baudrate); SR_PRIV int sr_serial_extract_options(GSList *options, const char **serial_device, const char **serial_options); SR_PRIV int serial_source_add(struct sr_serial_dev_inst *serial, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data); + int timeout, sr_receive_data_callback cb, void *cb_data); SR_PRIV int serial_source_remove(struct sr_serial_dev_inst *serial); SR_PRIV GSList *sr_serial_find_usb(uint16_t vendor_id, uint16_t product_id); #endif @@ -392,7 +393,7 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration, SR_PRIV GSList *sr_usb_find(libusb_context *usb_ctx, const char *conn); SR_PRIV int sr_usb_open(libusb_context *usb_ctx, struct sr_usb_dev_inst *usb); SR_PRIV int usb_source_add(struct sr_context *ctx, int timeout, - sr_receive_data_callback_t cb, void *cb_data); + sr_receive_data_callback cb, void *cb_data); SR_PRIV int usb_source_remove(struct sr_context *ctx); #endif @@ -443,7 +444,7 @@ struct sr_scpi_dev_inst { const char *resource, char **params, const char *serialcomm); int (*open)(void *priv); int (*source_add)(void *priv, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data); + int timeout, sr_receive_data_callback cb, void *cb_data); int (*source_remove)(void *priv); int (*send)(void *priv, const char *command); int (*read_begin)(void *priv); @@ -460,7 +461,7 @@ SR_PRIV struct sr_scpi_dev_inst *scpi_dev_inst_new(struct drv_context *drvc, const char *resource, const char *serialcomm); SR_PRIV int sr_scpi_open(struct sr_scpi_dev_inst *scpi); SR_PRIV int sr_scpi_source_add(struct sr_scpi_dev_inst *scpi, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data); + int timeout, sr_receive_data_callback cb, void *cb_data); SR_PRIV int sr_scpi_source_remove(struct sr_scpi_dev_inst *scpi); SR_PRIV int sr_scpi_send(struct sr_scpi_dev_inst *scpi, const char *format, ...); diff --git a/libsigrok.h b/libsigrok.h index 3235ddf2..552e1075 100644 --- a/libsigrok.h +++ b/libsigrok.h @@ -132,7 +132,7 @@ enum sr_loglevel { #endif /** Type definition for callback function for data reception. */ -typedef int (*sr_receive_data_callback_t)(int fd, int revents, void *cb_data); +typedef int (*sr_receive_data_callback)(int fd, int revents, void *cb_data); /** Data types used by sr_config_info(). */ enum sr_datatype { diff --git a/log.c b/log.c index 47c37b88..44bd49c5 100644 --- a/log.c +++ b/log.c @@ -48,13 +48,13 @@ static int sr_logv(void *cb_data, int loglevel, const char *format, va_list args); /* Pointer to the currently selected log callback. Default: sr_logv(). */ -static sr_log_callback_t sr_log_callback = sr_logv; +static sr_log_callback sr_log_cb = sr_logv; /* * Pointer to private data that can be passed to the log callback. * This can be used (for example) by C++ GUIs to pass a "this" pointer. */ -static void *sr_log_callback_data = NULL; +static void *sr_log_cb_data = NULL; /* Log domain (a short string that is used as prefix for all messages). */ /** @cond PRIVATE */ @@ -166,7 +166,7 @@ SR_API char *sr_log_logdomain_get(void) * * @since 0.1.0 */ -SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data) +SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data) { if (!cb) { sr_err("log: %s: cb was NULL", __func__); @@ -175,8 +175,8 @@ SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data) /* Note: 'cb_data' is allowed to be NULL. */ - sr_log_callback = cb; - sr_log_callback_data = cb_data; + sr_log_cb = cb; + sr_log_cb_data = cb_data; return SR_OK; } @@ -184,7 +184,7 @@ SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data) /** * Set the libsigrok log callback to the default built-in one. * - * Additionally, the internal 'sr_log_callback_data' pointer is set to NULL. + * Additionally, the internal 'sr_log_cb_data' pointer is set to NULL. * * @return SR_OK upon success, a negative error code otherwise. * @@ -196,8 +196,8 @@ SR_API int sr_log_callback_set_default(void) * Note: No log output in this function, as it should safely work * even if the currently set log callback is buggy/broken. */ - sr_log_callback = sr_logv; - sr_log_callback_data = NULL; + sr_log_cb = sr_logv; + sr_log_cb_data = NULL; return SR_OK; } @@ -228,7 +228,7 @@ SR_PRIV int sr_log(int loglevel, const char *format, ...) va_list args; va_start(args, format); - ret = sr_log_callback(sr_log_callback_data, loglevel, format, args); + ret = sr_log_cb(sr_log_cb_data, loglevel, format, args); va_end(args); return ret; @@ -241,7 +241,7 @@ SR_PRIV int sr_spew(const char *format, ...) va_list args; va_start(args, format); - ret = sr_log_callback(sr_log_callback_data, SR_LOG_SPEW, format, args); + ret = sr_log_cb(sr_log_cb_data, SR_LOG_SPEW, format, args); va_end(args); return ret; @@ -254,7 +254,7 @@ SR_PRIV int sr_dbg(const char *format, ...) va_list args; va_start(args, format); - ret = sr_log_callback(sr_log_callback_data, SR_LOG_DBG, format, args); + ret = sr_log_cb(sr_log_cb_data, SR_LOG_DBG, format, args); va_end(args); return ret; @@ -267,7 +267,7 @@ SR_PRIV int sr_info(const char *format, ...) va_list args; va_start(args, format); - ret = sr_log_callback(sr_log_callback_data, SR_LOG_INFO, format, args); + ret = sr_log_cb(sr_log_cb_data, SR_LOG_INFO, format, args); va_end(args); return ret; @@ -280,7 +280,7 @@ SR_PRIV int sr_warn(const char *format, ...) va_list args; va_start(args, format); - ret = sr_log_callback(sr_log_callback_data, SR_LOG_WARN, format, args); + ret = sr_log_cb(sr_log_cb_data, SR_LOG_WARN, format, args); va_end(args); return ret; @@ -293,7 +293,7 @@ SR_PRIV int sr_err(const char *format, ...) va_list args; va_start(args, format); - ret = sr_log_callback(sr_log_callback_data, SR_LOG_ERR, format, args); + ret = sr_log_cb(sr_log_cb_data, SR_LOG_ERR, format, args); va_end(args); return ret; diff --git a/proto.h b/proto.h index 12382502..49353d55 100644 --- a/proto.h +++ b/proto.h @@ -33,12 +33,12 @@ SR_API int sr_exit(struct sr_context *ctx); /*--- log.c -----------------------------------------------------------------*/ -typedef int (*sr_log_callback_t)(void *cb_data, int loglevel, - const char *format, va_list args); +typedef int (*sr_log_callback)(void *cb_data, int loglevel, + const char *format, va_list args); SR_API int sr_log_loglevel_set(int loglevel); SR_API int sr_log_loglevel_get(void); -SR_API int sr_log_callback_set(sr_log_callback_t cb, void *cb_data); +SR_API int sr_log_callback_set(sr_log_callback cb, void *cb_data); SR_API int sr_log_callback_set_default(void); SR_API int sr_log_logdomain_set(const char *logdomain); SR_API char *sr_log_logdomain_get(void); @@ -80,7 +80,7 @@ SR_API const struct sr_config_info *sr_config_info_name_get(const char *optname) /*--- session.c -------------------------------------------------------------*/ -typedef void (*sr_datafeed_callback_t)(const struct sr_dev_inst *sdi, +typedef void (*sr_datafeed_callback)(const struct sr_dev_inst *sdi, const struct sr_datafeed_packet *packet, void *cb_data); /* Session setup */ @@ -93,7 +93,7 @@ SR_API int sr_session_dev_list(GSList **devlist); /* Datafeed setup */ SR_API int sr_session_datafeed_callback_remove_all(void); -SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb, +SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback cb, void *cb_data); /* Session control */ @@ -107,11 +107,11 @@ SR_API int sr_session_save_init(const char *filename, uint64_t samplerate, SR_API int sr_session_append(const char *filename, unsigned char *buf, int unitsize, int units); SR_API int sr_session_source_add(int fd, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data); + sr_receive_data_callback cb, void *cb_data); SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout, - sr_receive_data_callback_t cb, void *cb_data); + sr_receive_data_callback cb, void *cb_data); SR_API int sr_session_source_add_channel(GIOChannel *channel, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data); + int timeout, sr_receive_data_callback cb, void *cb_data); SR_API int sr_session_source_remove(int fd); SR_API int sr_session_source_remove_pollfd(GPollFD *pollfd); SR_API int sr_session_source_remove_channel(GIOChannel *channel); diff --git a/session.c b/session.c index cae9126e..263185c1 100644 --- a/session.c +++ b/session.c @@ -45,7 +45,7 @@ struct source { int timeout; - sr_receive_data_callback_t cb; + sr_receive_data_callback cb; void *cb_data; /* This is used to keep track of the object (fd, pollfd or channel) which is @@ -55,7 +55,7 @@ struct source { }; struct datafeed_callback { - sr_datafeed_callback_t cb; + sr_datafeed_callback cb; void *cb_data; }; @@ -252,7 +252,7 @@ SR_API int sr_session_datafeed_callback_remove_all(void) * @retval SR_OK Success. * @retval SR_ERR_BUG No session exists. */ -SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback_t cb, void *cb_data) +SR_API int sr_session_datafeed_callback_add(sr_datafeed_callback cb, void *cb_data) { struct datafeed_callback *cb_struct; @@ -584,7 +584,7 @@ SR_PRIV int sr_session_send(const struct sr_dev_inst *sdi, * @retval SR_ERR_MALLOC Memory allocation error. */ static int _sr_session_source_add(GPollFD *pollfd, int timeout, - sr_receive_data_callback_t cb, void *cb_data, gintptr poll_object) + sr_receive_data_callback cb, void *cb_data, gintptr poll_object) { struct source *new_sources, *s; GPollFD *new_pollfds; @@ -640,7 +640,7 @@ static int _sr_session_source_add(GPollFD *pollfd, int timeout, * @retval SR_ERR_MALLOC Memory allocation error. */ SR_API int sr_session_source_add(int fd, int events, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { GPollFD p; @@ -663,7 +663,7 @@ SR_API int sr_session_source_add(int fd, int events, int timeout, * @retval SR_ERR_MALLOC Memory allocation error. */ SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout, - sr_receive_data_callback_t cb, void *cb_data) + sr_receive_data_callback cb, void *cb_data) { return _sr_session_source_add(pollfd, timeout, cb, cb_data, (gintptr)pollfd); @@ -683,7 +683,7 @@ SR_API int sr_session_source_add_pollfd(GPollFD *pollfd, int timeout, * @retval SR_ERR_MALLOC Memory allocation error. */ SR_API int sr_session_source_add_channel(GIOChannel *channel, int events, - int timeout, sr_receive_data_callback_t cb, void *cb_data) + int timeout, sr_receive_data_callback cb, void *cb_data) { GPollFD p; diff --git a/std.c b/std.c index 1a65b039..1b9c6000 100644 --- a/std.c +++ b/std.c @@ -182,7 +182,7 @@ SR_PRIV int std_serial_dev_close(struct sr_dev_inst *sdi) * @retval SR_ERR Other errors. */ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi, - void *cb_data, dev_close_t dev_close_fn, + void *cb_data, dev_close_callback dev_close_fn, struct sr_serial_dev_inst *serial, const char *prefix) { int ret; @@ -245,7 +245,7 @@ SR_PRIV int std_serial_dev_acquisition_stop(struct sr_dev_inst *sdi, * @return SR_OK on success. */ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, - std_dev_clear_t clear_private) + std_dev_clear_callback clear_private) { struct drv_context *drvc; struct sr_dev_inst *sdi;