]> sigrok.org Git - libsigrok.git/commitdiff
uni-t-dmm: style nits, copy loop vs memmove
authorGerhard Sittig <redacted>
Wed, 21 Feb 2018 17:03:11 +0000 (18:03 +0100)
committerUwe Hermann <redacted>
Sat, 3 Mar 2018 17:58:59 +0000 (18:58 +0100)
src/hardware/uni-t-dmm/protocol.c

index 111770838f077310559b8fbbbc765c995734d2c1..94abb16bc8ae1277d07d5bf8511999803469c8e6 100644 (file)
@@ -258,8 +258,8 @@ static int get_and_handle_data(struct sr_dev_inst *sdi)
        }
 
        /* Move remaining bytes to beginning of buffer. */
-       for (i = 0; i < devc->buflen - devc->bufoffset; i++)
-               pbuf[i] = pbuf[devc->bufoffset + i];
+       if (devc->bufoffset < devc->buflen)
+               memmove(pbuf, pbuf + devc->bufoffset, devc->buflen - devc->bufoffset);
        devc->buflen -= devc->bufoffset;
 
        return SR_OK;