Skip to content

Commit 587ee11

Browse files
committed
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.
1 parent c179e47 commit 587ee11

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/hardware/korad-kaxxxxp/protocol.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ static void give_device_time_to_process(struct dev_context *devc)
155155
{
156156
int64_t sleeping_time;
157157

158+
if (!devc->req_sent_at)
159+
return;
160+
158161
sleeping_time = devc->req_sent_at + (DEVICE_PROCESSING_TIME_MS * 1000);
159162
sleeping_time -= g_get_monotonic_time();
160163

0 commit comments

Comments
 (0)