← KD100

Fix main loop exiting immediately after USB timeout

bbff9118cd8d10e7d9a24081851098510dc0be7d · Claude · Feb 7, 2026 05:02

The loop condition `while (err >= 0)` was failing after a timeout
because LIBUSB_ERROR_TIMEOUT is -7. Even with `continue`, the loop
condition was still checked and the loop exited.

Fix: Reset err to 0 before continuing after a timeout.

https://claude.ai/code/session_01H5sr8TkRyt6U1vdkVZRRvy

+1 · 1 file changed

  • src/device.c +1 −0
diff --git a/src/device.c b/src/device.c
index 3f49b8c..b515ece 100644
--- a/src/device.c
+++ b/src/device.c
@@ -390,6 +390,7 @@ void device_run(libusb_context* ctx, config_t* config, int debug, int accept, in
 
                     if (err == LIBUSB_ERROR_TIMEOUT) {
                         // Normal timeout - just continue to process OSD events
+                        err = 0;  // Reset err so loop continues
                         continue;
                     }
                     if (err == LIBUSB_ERROR_PIPE)