From: Gerhard Sittig Date: Sat, 25 Feb 2023 15:29:28 +0000 (+0100) Subject: korad-kaxxxxp: tweak first "give time to process" invocation X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=587ee11535e1c668cafbc72fc68278e0b31fbe76;p=libsigrok.git korad-kaxxxxp: tweak first "give time to process" invocation 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. --- diff --git a/src/hardware/korad-kaxxxxp/protocol.c b/src/hardware/korad-kaxxxxp/protocol.c index 4f09dbc7..ce6032c8 100644 --- a/src/hardware/korad-kaxxxxp/protocol.c +++ b/src/hardware/korad-kaxxxxp/protocol.c @@ -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();