From: Bert Vermeulen Date: Mon, 21 Apr 2014 12:46:49 +0000 (+0200) Subject: ols: Allow disabling all channels. X-Git-Tag: libsigrok-0.3.0~71 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1e1dac0c0707f73a4c86e27cd02bb90515550354;p=libsigrok.git ols: Allow disabling all channels. This fixed bug 316. --- diff --git a/hardware/openbench-logic-sniffer/api.c b/hardware/openbench-logic-sniffer/api.c index bcc41ed2..b99d8e72 100644 --- a/hardware/openbench-logic-sniffer/api.c +++ b/hardware/openbench-logic-sniffer/api.c @@ -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);