From b463cdc9cdcec6c53b0a4aa468f249c79db13efc Mon Sep 17 00:00:00 2001 From: nirenjan Date: Wed, 21 Oct 2026 15:23:20 -0700 Subject: [PATCH] refactor: Reduce cyclomatic complexity in daemon/device --- daemon/device.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/daemon/device.c b/daemon/device.c index 78f22db..687b1e1 100644 --- a/daemon/device.c +++ b/daemon/device.c @@ -39,13 +39,12 @@ static void *x52_dev_thr(void *param) if (!libx52_is_connected(x52_dev)) { PINELOG_TRACE("Attempting to connect to X52 device"); rc = libx52_connect(x52_dev); - if (rc != LIBX52_SUCCESS) { - if (rc != LIBX52_ERROR_NO_DEVICE) { - PINELOG_ERROR(_("Error %d connecting to device: %s"), - rc, libx52_strerror(rc)); - } else { - PINELOG_TRACE("No compatible X52 device found"); - } + if (rc == LIBX52_ERROR_NO_DEVICE) { + PINELOG_TRACE("No compatible X52 device found"); + PINELOG_TRACE("Sleeping for %d seconds before trying to acquire device again", DEV_ACQ_DELAY); + sleep(DEV_ACQ_DELAY); + } else if (rc != LIBX52_SUCCESS) { + PINELOG_ERROR(_("Error %d connecting to device: %s"), rc, libx52_strerror(rc)); PINELOG_TRACE("Sleeping for %d seconds before trying to acquire device again", DEV_ACQ_DELAY); sleep(DEV_ACQ_DELAY); } else {