From 82f32823b03df85192e50732e4230eb6a44cb023 Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 12 Nov 2023 16:06:44 +0100 Subject: [PATCH] Check for error properly --- input_dev.c | 11 ++++++----- input_dev.h | 2 +- output_dev.h | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/input_dev.c b/input_dev.c index 54cb920..0e8dab7 100644 --- a/input_dev.c +++ b/input_dev.c @@ -113,10 +113,11 @@ static void* iio_read_thread_func(void* ptr) { continue; } - const int res = dev_iio_read(ctx->iio_dev, msg->ev, msg->ev_size, &msg->ev_count); - if (res == 0) { - - } else if (res == -ENOMEM) { + rc = dev_iio_read(ctx->iio_dev, msg->ev, msg->ev_size, &msg->ev_count); + if (rc == 0) { + fprintf(stderr, "Error: reading %s: %d\n", dev_iio_get_name(ctx->iio_dev), rc); + break; + } else if (rc == -ENOMEM) { fprintf(stderr, "Error: out-of-memory will skip the current frame.\n"); continue; } @@ -274,7 +275,7 @@ static void input_iio( } sprintf(path, "%s%s", iio_path, dir->d_name); - printf("testing %s", path); + printf("testing %s\n", path); // check if that has been already opened // open_sysfs diff --git a/input_dev.h b/input_dev.h index fc41d5c..4767c92 100644 --- a/input_dev.h +++ b/input_dev.h @@ -2,7 +2,7 @@ #include "queue.h" -#undef INCLUDE_INPUT_DEBUG +#define INCLUDE_INPUT_DEBUG #define INPUT_DEV_CTRL_FLAG_EXIT 0x00000001U diff --git a/output_dev.h b/output_dev.h index 82e2f8d..faee018 100644 --- a/output_dev.h +++ b/output_dev.h @@ -39,7 +39,7 @@ #define GYRO_DEADZONE 1 // degrees/s to count as zero movement #undef INCLUDE_TIMESTAMP -#define INCLUDE_OUTPUT_DEBUG +#undef INCLUDE_OUTPUT_DEBUG typedef enum output_dev_type { output_dev_gamepad,