#ifdef HAVE_SERIAL_COMM
-/* See if a (assumed opened) serial port is of any supported type. */
+/* See if an (assumed opened) serial port is of any supported type. */
static int dev_is_supported(struct sr_serial_dev_inst *serial)
{
- if (!serial)
- return 0;
- if (!serial->lib_funcs)
+ if (!serial || !serial->lib_funcs)
return 0;
return 1;
*/
SR_PRIV void sr_ser_discard_queued_data(struct sr_serial_dev_inst *serial)
{
- if (!serial)
- return;
- if (!serial->rcv_buffer)
+ if (!serial || !serial->rcv_buffer)
return;
g_string_truncate(serial->rcv_buffer, 0);
*/
SR_PRIV size_t sr_ser_has_queued_data(struct sr_serial_dev_inst *serial)
{
- if (!serial)
- return 0;
- if (!serial->rcv_buffer)
+ if (!serial || !serial->rcv_buffer)
return 0;
return serial->rcv_buffer->len;
SR_PRIV void sr_ser_queue_rx_data(struct sr_serial_dev_inst *serial,
const uint8_t *data, size_t len)
{
- if (!serial)
- return;
- if (!data || !len)
+ if (!serial || !data || !len)
return;
if (serial->rx_chunk_cb_func)
size_t qlen;
GString *buf;
- if (!serial)
- return 0;
- if (!data || !len)
+ if (!serial || !data || !len)
return 0;
qlen = sr_ser_has_queued_data(serial);
/** @private */
SR_PRIV int serial_timeout(struct sr_serial_dev_inst *port, int num_bytes)
{
- int bits, baud;
- int ret;
- int timeout_ms;
+ int bits, baud, ret, timeout_ms;
/* Get the bitrate and frame length. */
bits = baud = 0;
* Immediately satisfy the caller's request from the RX buffer
* if the requested amount of data is available already.
*/
- if (sr_ser_has_queued_data(serial) >= count) {
- rc = sr_ser_unqueue_rx_data(serial, buf, count);
- return rc;
- }
+ if (sr_ser_has_queued_data(serial) >= count)
+ return sr_ser_unqueue_rx_data(serial, buf, count);
/*
* When a timeout was specified, then determine the deadline
/* Check whether the device was seen before. */
for (l = scan_args->addr_list; l; l = l->next) {
- if (strcmp(addr, l->data) == 0) {
+ if (strcmp(addr, l->data) == 0)
return;
- }
}
/* Substitute colons in the address by dashes. */
if (!vid_pids)
continue;
while (vid_pids->vid) {
- if (vid_pids->vid == vid && vid_pids->pid == pid) {
+ if (vid_pids->vid == vid && vid_pids->pid == pid)
return desc->chipname;
- }
vid_pids++;
}
}
* Immediately satisfy the caller's request from the RX buffer
* if the requested amount of data is available already.
*/
- if (sr_ser_has_queued_data(serial) >= count) {
- rc = sr_ser_unqueue_rx_data(serial, buf, count);
- return rc;
- }
+ if (sr_ser_has_queued_data(serial) >= count)
+ return sr_ser_unqueue_rx_data(serial, buf, count);
/*
* When a timeout was specified, then determine the deadline
if (got > count)
got = count;
sr_dbg("DBG: %s() passing %d bytes.", __func__, got);
- rc = sr_ser_unqueue_rx_data(serial, buf, count);
- return rc;
+ return sr_ser_unqueue_rx_data(serial, buf, count);
}
static struct ser_lib_functions serlib_hid = {