From: Aurelien Jacobs Date: Thu, 28 Jan 2016 22:17:50 +0000 (+0100) Subject: demo: fix infinite loop with 0 channels of one type X-Git-Tag: libsigrok-0.4.0~13 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9dfacd870618806defe64a0cbe1ccd330e11cb3d;p=libsigrok.git 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 --- 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 */