]> sigrok.org Git - libsigrok.git/commitdiff
dreamsourcelab-dslogic: avoid division by zero
authorGerhard Sittig <redacted>
Thu, 8 Feb 2018 22:16:40 +0000 (23:16 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:34:17 +0000 (21:34 +0100)
Do not align to block_size when its value is zero.

This was reported by clang's scan-build.

src/hardware/dreamsourcelab-dslogic/protocol.c

index 90b773d9cf970fe34d48193cea23de0792d046f5..863b4e3bac6f9a7ba88a6f25d768440dcc935c91 100644 (file)
@@ -914,6 +914,8 @@ static size_t get_buffer_size(const struct sr_dev_inst *sdi)
         */
        const size_t block_size = enabled_channel_count(sdi) * 512;
        const size_t s = 10 * to_bytes_per_ms(sdi);
+       if (!block_size)
+               return s;
        return ((s + block_size - 1) / block_size) * block_size;
 }