]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/brymen-dmm/protocol.c
usb: Skip add/remove of FD on destroyed source
[libsigrok.git] / src / hardware / brymen-dmm / protocol.c
index 5fb5ec29cb4c6cbfdcb87ffeb3bcb1b485a6bf3d..96ef6853f08f9dd024946facb3cee37dfe39dcaf 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include "protocol.h"
 
 static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi)
@@ -179,7 +180,9 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
 {
        int64_t start, time, byte_delay_us;
        size_t ibuf, i, maxlen;
-       int status, len, packet_len, stream_len;
+       ssize_t len, stream_len;
+       int packet_len;
+       int status;
 
        maxlen = *buflen;
 
@@ -195,7 +198,7 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
                len = serial_read_nonblocking(serial, &buf[ibuf], maxlen - ibuf);
                if (len > 0) {
                        ibuf += len;
-                       sr_spew("Read %d bytes.", len);
+                       sr_spew("Read %zd bytes.", len);
                }
 
                time = g_get_monotonic_time() - start;
@@ -247,14 +250,14 @@ SR_PRIV int brymen_stream_detect(struct sr_serial_dev_inst *serial,
 
                if (time >= (int64_t)timeout_ms) {
                        /* Timeout */
-                       sr_dbg("Detection timed out after %dms.", time);
+                       sr_dbg("Detection timed out after %" PRIi64 "ms.", time);
                        break;
                }
                g_usleep(byte_delay_us);
        }
 
        *buflen = ibuf;
-       sr_err("Didn't find a valid packet (read %d bytes).", ibuf);
+       sr_err("Didn't find a valid packet (read %zu bytes).", ibuf);
 
        return SR_ERR;
 }