]> sigrok.org Git - libsigrok.git/commitdiff
korad-kaxxxxp: tweak first "give time to process" invocation
authorGerhard Sittig <redacted>
Sat, 25 Feb 2023 15:29:28 +0000 (16:29 +0100)
committerGerhard Sittig <redacted>
Sun, 26 Feb 2023 06:45:11 +0000 (07:45 +0100)
The give_device_time_to_process() routine unconditionally calculated
with a "time since last command transmission" value which may not have
been assigned to in the first invocation of a getter or setter.

Just don't sleep at all when nothing was sent before. Avoids a
dependency on implementation details of signed integer math.

src/hardware/korad-kaxxxxp/protocol.c

index 4f09dbc7c80e970ba99caf3bca2b612d6e252594..ce6032c84af086cca715cb768bbb2120498fdba1 100644 (file)
@@ -155,6 +155,9 @@ static void give_device_time_to_process(struct dev_context *devc)
 {
        int64_t sleeping_time;
 
+       if (!devc->req_sent_at)
+               return;
+
        sleeping_time = devc->req_sent_at + (DEVICE_PROCESSING_TIME_MS * 1000);
        sleeping_time -= g_get_monotonic_time();