]> sigrok.org Git - libsigrok.git/commitdiff
ols: Allow disabling all channels.
authorBert Vermeulen <redacted>
Mon, 21 Apr 2014 12:46:49 +0000 (14:46 +0200)
committerBert Vermeulen <redacted>
Mon, 21 Apr 2014 12:46:49 +0000 (14:46 +0200)
This fixed bug 316.

hardware/openbench-logic-sniffer/api.c

index bcc41ed2522d200b7516c943844336f4b8c7c437..b99d8e72125545258214a1513389482ef5fa116c 100644 (file)
@@ -399,6 +399,12 @@ static int config_list(int key, GVariant **data, const struct sr_dev_inst *sdi,
                        if (devc->channel_mask & (0xff << (i * 8)))
                                num_channels++;
                }
+               if (num_channels == 0) {
+                       /* This can happen, but shouldn't cause too much drama.
+                        * However we can't continue because the code below would
+                        * divide by zero. */
+                       break;
+               }
                grange[0] = g_variant_new_uint64(MIN_NUM_SAMPLES);
                grange[1] = g_variant_new_uint64(devc->max_samples / num_channels);
                *data = g_variant_new_tuple(grange, 2);