]> sigrok.org Git - libsigrok.git/commitdiff
demo: fix infinite loop with 0 channels of one type
authorAurelien Jacobs <redacted>
Thu, 28 Jan 2016 22:17:50 +0000 (23:17 +0100)
committerUwe Hermann <redacted>
Thu, 28 Jan 2016 22:41:19 +0000 (23:41 +0100)
The following command line exhibits the inifinit loop:
  sigrok-cli -d demo:analog_channels=0 --samples=8

src/hardware/demo/demo.c

index 1b25872755a451dcecaa0ed242fc4b08010fea0b..6042cfd98fca6bb029e414fcd76e14a984996ed4 100644 (file)
@@ -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 */