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.
This commit is contained in:
parent
9ee3a10390
commit
a155fb717b
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user