From 1e1dac0c0707f73a4c86e27cd02bb90515550354 Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Mon, 21 Apr 2014 14:46:49 +0200 Subject: [PATCH] ols: Allow disabling all channels. This fixed bug 316. --- hardware/openbench-logic-sniffer/api.c | 6 ++++++ 1 file changed, 6 insertions(+) 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);