From ba6a8a43f722bd0b2f3fca953e119d0002ec2733 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 4 Sep 2020 08:10:00 +0200 Subject: [PATCH] Use an unsigned value to represent the undefined state This fixes some more -Wsign-compare compiler warnings. --- src/cochran_commander.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cochran_commander.c b/src/cochran_commander.c index 7e8348e..e3677e9 100644 --- a/src/cochran_commander.c +++ b/src/cochran_commander.c @@ -41,6 +41,8 @@ #define COCHRAN_MODEL_EMC_16 4 #define COCHRAN_MODEL_EMC_20 5 +#define UNDEFINED 0xFFFFFFFF + typedef enum cochran_endian_t { ENDIAN_LE, ENDIAN_BE, @@ -57,8 +59,8 @@ typedef struct cochran_data_t { unsigned char *logbook; unsigned short int dive_count; - int fp_dive_num; - int invalid_profile_dive_num; + unsigned int fp_dive_num; + unsigned int invalid_profile_dive_num; unsigned int logbook_size; } cochran_data_t; @@ -622,7 +624,7 @@ cochran_commander_find_fingerprint(cochran_commander_device_t *device, cochran_d int profile_capacity_remaining = device->layout->rb_profile_end - device->layout->rb_profile_begin; unsigned int dive_count = 0; - data->fp_dive_num = -1; + data->fp_dive_num = UNDEFINED; // Start at end of log if (data->dive_count < device->layout->rb_logbook_entry_count) @@ -631,7 +633,7 @@ cochran_commander_find_fingerprint(cochran_commander_device_t *device, cochran_d dive_count = device->layout->rb_logbook_entry_count; unsigned int sample_read_size = 0; - data->invalid_profile_dive_num = -1; + data->invalid_profile_dive_num = UNDEFINED; // Remove the pre-dive events that occur after the last dive unsigned int rb_head_ptr = 0; @@ -952,7 +954,7 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call } // Change tail to dive following the fingerprint dive. - if (data.fp_dive_num > -1) + if (data.fp_dive_num != UNDEFINED) tail_dive = (data.fp_dive_num + 1) % layout->rb_logbook_entry_count; // Number of dives to read