From 9dfacd870618806defe64a0cbe1ccd330e11cb3d Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Thu, 28 Jan 2016 23:17:50 +0100 Subject: [PATCH] demo: fix infinite loop with 0 channels of one type The following command line exhibits the inifinit loop: sigrok-cli -d demo:analog_channels=0 --samples=8 --- src/hardware/demo/demo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware/demo/demo.c b/src/hardware/demo/demo.c index 1b258727..6042cfd9 100644 --- a/src/hardware/demo/demo.c +++ b/src/hardware/demo/demo.c @@ -784,8 +784,8 @@ static int prepare_data(int fd, int revents, void *cb_data) */ todo_us = samples_todo * G_USEC_PER_SEC / devc->cur_samplerate; - logic_done = 0; - analog_done = 0; + logic_done = devc->num_logic_channels > 0 ? 0 : samples_todo; + analog_done = devc->num_analog_channels > 0 ? 0 : samples_todo; while (logic_done < samples_todo || analog_done < samples_todo) { /* Logic */