{
struct dmm_info *dmm;
struct dev_context *devc;
- int len, i, offset = 0;
+ int len, offset;
struct sr_serial_dev_inst *serial;
dmm = (struct dmm_info *)sdi->driver;
devc->buflen += len;
/* Now look for packets in that data. */
+ offset = 0;
while ((devc->buflen - offset) >= dmm->packet_size) {
if (dmm->packet_valid(devc->buf + offset)) {
handle_packet(devc->buf + offset, sdi, info);
}
/* If we have any data left, move it to the beginning of our buffer. */
- for (i = 0; i < devc->buflen - offset; i++)
- devc->buf[i] = devc->buf[offset + i];
+ if (devc->buflen > offset)
+ memmove(devc->buf, devc->buf + offset, devc->buflen - offset);
devc->buflen -= offset;
}