From a155fb717b1edc6068af974771603561d0258d5a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 27 Nov 2015 19:34:06 +0100 Subject: [PATCH] Add extra debug information to the error messages. With the extra debug information it's easier to investigate the underlying problem, without needing a debugger. --- src/cressi_edy.c | 8 ++++---- src/cressi_leonardo.c | 4 ++-- src/diverite_nitekq.c | 4 ++-- src/hw_frog.c | 2 +- src/mares_common.c | 6 +++--- src/mares_darwin.c | 4 ++-- src/mares_iconhd.c | 2 +- src/oceanic_common.c | 4 ++-- src/suunto_common2.c | 10 +++++----- src/zeagle_n2ition3.c | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cressi_edy.c b/src/cressi_edy.c index 504b79c..2a7b271 100644 --- a/src/cressi_edy.c +++ b/src/cressi_edy.c @@ -444,7 +444,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v last < layout->rb_logbook_begin || last >= layout->rb_logbook_end) { if (last == 0xFF) return DC_STATUS_SUCCESS; - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%02x 0x%02x).", first, last); return DC_STATUS_DATAFORMAT; } @@ -454,7 +454,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v // Get the profile pointer. unsigned int eop = array_uint_le (logbook + layout->config + 2, layout->rb_logbook_size) * SZ_PAGE + layout->rb_profile_begin; if (eop < layout->rb_profile_begin || eop >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x).", eop); return DC_STATUS_DATAFORMAT; } @@ -469,7 +469,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v // Get the pointer to the profile data. unsigned int current = array_uint_le (logbook + idx * layout->rb_logbook_size, layout->rb_logbook_size) * SZ_PAGE + layout->rb_profile_begin; if (current < layout->rb_profile_begin || current >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x).", current); return DC_STATUS_DATAFORMAT; } @@ -532,7 +532,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v // Get the pointer to the profile data. unsigned int current = array_uint_le (logbook + idx * layout->rb_logbook_size, layout->rb_logbook_size) * SZ_PAGE + layout->rb_profile_begin; if (current < layout->rb_profile_begin || current >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x).", current); free(buffer); return DC_STATUS_DATAFORMAT; } diff --git a/src/cressi_leonardo.c b/src/cressi_leonardo.c index b2df764..2d6d177 100644 --- a/src/cressi_leonardo.c +++ b/src/cressi_leonardo.c @@ -343,7 +343,7 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[] if (header < RB_PROFILE_BEGIN || header + 2 > RB_PROFILE_END || footer < RB_PROFILE_BEGIN || footer + 2 > RB_PROFILE_END) { - ERROR (context, "Invalid ringbuffer pointer detected."); + ERROR (context, "Invalid ringbuffer pointer detected (0x%04x 0x%04x).", header, footer); free (buffer); return DC_STATUS_DATAFORMAT; } @@ -352,7 +352,7 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[] unsigned int header2 = array_uint16_le (data + footer); unsigned int footer2 = array_uint16_le (data + header); if (header2 != header || footer2 != footer) { - ERROR (context, "Invalid ringbuffer pointer detected."); + ERROR (context, "Invalid ringbuffer pointer detected (0x%04x 0x%04x).", header2, footer2); free (buffer); return DC_STATUS_DATAFORMAT; } diff --git a/src/diverite_nitekq.c b/src/diverite_nitekq.c index 661588f..6ca5356 100644 --- a/src/diverite_nitekq.c +++ b/src/diverite_nitekq.c @@ -381,7 +381,7 @@ diverite_nitekq_extract_dives (dc_device_t *abstract, const unsigned char data[] // Get the end of profile pointer. unsigned int eop = array_uint16_be(data + EOP); if (eop < RB_PROFILE_BEGIN || eop >= RB_PROFILE_END) { - ERROR (context, "Invalid ringbuffer pointer detected."); + ERROR (context, "Invalid ringbuffer pointer detected (0x%04x).", eop); free (buffer); return DC_STATUS_DATAFORMAT; } @@ -402,7 +402,7 @@ diverite_nitekq_extract_dives (dc_device_t *abstract, const unsigned char data[] // Get the address of the profile data. unsigned int address = array_uint16_be(data + ADDRESS + i * 2); if (address < RB_PROFILE_BEGIN || address >= RB_PROFILE_END) { - ERROR (context, "Invalid ringbuffer pointer detected."); + ERROR (context, "Invalid ringbuffer pointer detected (0x%04x).", address); free (buffer); return DC_STATUS_DATAFORMAT; } diff --git a/src/hw_frog.c b/src/hw_frog.c index ec760ac..43bc307 100644 --- a/src/hw_frog.c +++ b/src/hw_frog.c @@ -409,7 +409,7 @@ hw_frog_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void end < RB_PROFILE_BEGIN || end >= RB_PROFILE_END) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%06x 0x%06x).", begin, end); free (header); return DC_STATUS_DATAFORMAT; } diff --git a/src/mares_common.c b/src/mares_common.c index 7f0655e..669de99 100644 --- a/src/mares_common.c +++ b/src/mares_common.c @@ -224,7 +224,7 @@ mares_common_extract_dives (dc_context_t *context, const mares_common_layout_t * // Get the end of the profile ring buffer. unsigned int eop = array_uint16_le (data + 0x6B); if (eop < layout->rb_profile_begin || eop >= layout->rb_profile_end) { - ERROR (context, "Ringbuffer pointer out of range."); + ERROR (context, "Ringbuffer pointer out of range (0x%04x).", eop); return DC_STATUS_DATAFORMAT; } @@ -311,7 +311,7 @@ mares_common_extract_dives (dc_context_t *context, const mares_common_layout_t * // something is wrong and an error is returned. unsigned int length = array_uint16_le (buffer + offset); if (length != nbytes) { - ERROR (context, "Calculated and stored size are not equal."); + ERROR (context, "Calculated and stored size are not equal (%u %u).", length, nbytes); free (buffer); return DC_STATUS_DATAFORMAT; } @@ -339,7 +339,7 @@ mares_common_extract_dives (dc_context_t *context, const mares_common_layout_t * // equals the number of freedives in the profile data. If // both values are different, the profile data is incomplete. if (count != nsamples) { - ERROR (context, "Unexpected number of freedive sessions."); + ERROR (context, "Unexpected number of freedive sessions (%u %u).", count, nsamples); free (buffer); return DC_STATUS_DATAFORMAT; } diff --git a/src/mares_darwin.c b/src/mares_darwin.c index 5c2513b..957e7d9 100644 --- a/src/mares_darwin.c +++ b/src/mares_darwin.c @@ -267,14 +267,14 @@ mares_darwin_extract_dives (dc_device_t *abstract, const unsigned char data[], u // Get the profile pointer. unsigned int eop = array_uint16_be (data + 0x8A); if (eop < layout->rb_profile_begin || eop >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x).", eop); return DC_STATUS_DATAFORMAT; } // Get the logbook index. unsigned int last = data[0x8C]; if (last >= layout->rb_logbook_count) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%02x).", last); return DC_STATUS_DATAFORMAT; } diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 49b7300..93b2dfc 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -478,7 +478,7 @@ mares_iconhd_extract_dives (dc_device_t *abstract, const unsigned char data[], u break; } if (eop < layout->rb_profile_begin || eop >= layout->rb_profile_end) { - ERROR (context, "Ringbuffer pointer out of range."); + ERROR (context, "Ringbuffer pointer out of range (0x%08x).", eop); return DC_STATUS_DATAFORMAT; } diff --git a/src/oceanic_common.c b/src/oceanic_common.c index c51836f..f204309 100644 --- a/src/oceanic_common.c +++ b/src/oceanic_common.c @@ -261,7 +261,7 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac rb_logbook_last < layout->rb_logbook_begin || rb_logbook_last >= layout->rb_logbook_end) { - ERROR (abstract->context, "Invalid logbook pointer detected."); + ERROR (abstract->context, "Invalid logbook pointer detected (0x%04x 0x%04x).", rb_logbook_first, rb_logbook_last); return DC_STATUS_DATAFORMAT; } @@ -436,7 +436,7 @@ oceanic_common_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac rb_entry_last < layout->rb_profile_begin || rb_entry_last >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%06x 0x%06x).", rb_entry_first, rb_entry_last); status = DC_STATUS_DATAFORMAT; begin = current + layout->rb_logbook_entry_size; abort = 1; diff --git a/src/suunto_common2.c b/src/suunto_common2.c index 366e63a..2149612 100644 --- a/src/suunto_common2.c +++ b/src/suunto_common2.c @@ -293,7 +293,7 @@ suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac begin < layout->rb_profile_begin || begin >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x 0x%04x 0x%04x %u).", begin, last, end, count); return DC_STATUS_DATAFORMAT; } @@ -335,7 +335,7 @@ suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac unsigned int size = RB_PROFILE_DISTANCE (layout, current, previous, 1); if (size < 4 || size > remaining) { - ERROR (abstract->context, "Unexpected profile size."); + ERROR (abstract->context, "Unexpected profile size (%u %u).", size, remaining); free (data); return DC_STATUS_DATAFORMAT; } @@ -400,12 +400,12 @@ suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac next < layout->rb_profile_begin || next >= layout->rb_profile_end) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x 0x%04x).", prev, next); free (data); return DC_STATUS_DATAFORMAT; } if (next != previous && next != current) { - ERROR (abstract->context, "Profiles are not continuous."); + ERROR (abstract->context, "Profiles are not continuous (0x%04x 0x%04x 0x%04x).", current, next, previous); free (data); return DC_STATUS_DATAFORMAT; } @@ -422,7 +422,7 @@ suunto_common2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac return DC_STATUS_SUCCESS; } } else { - ERROR (abstract->context, "Skipping incomplete dive."); + ERROR (abstract->context, "Skipping incomplete dive (0x%04x 0x%04x 0x%04x).", current, next, previous); status = DC_STATUS_DATAFORMAT; } diff --git a/src/zeagle_n2ition3.c b/src/zeagle_n2ition3.c index 5c077d4..1c1dcf1 100644 --- a/src/zeagle_n2ition3.c +++ b/src/zeagle_n2ition3.c @@ -302,7 +302,7 @@ zeagle_n2ition3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callba last < RB_LOGBOOK_BEGIN || last >= RB_LOGBOOK_END) { if (last == 0xFF) return DC_STATUS_SUCCESS; - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%02x 0x%02x).", first, last); return DC_STATUS_DATAFORMAT; } @@ -312,7 +312,7 @@ zeagle_n2ition3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callba // Get the profile pointer. unsigned int eop = array_uint16_le (config + 0x7E); if (eop < RB_PROFILE_BEGIN || eop >= RB_PROFILE_END) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x).", eop); return DC_STATUS_DATAFORMAT; } @@ -327,7 +327,7 @@ zeagle_n2ition3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callba // Get the pointer to the profile data. unsigned int current = array_uint16_le (config + 2 * idx); if (current < RB_PROFILE_BEGIN || current >= RB_PROFILE_END) { - ERROR (abstract->context, "Invalid ringbuffer pointer detected."); + ERROR (abstract->context, "Invalid ringbuffer pointer detected (0x%04x).", current); return DC_STATUS_DATAFORMAT; }