Skip to content

Commit 7db15b3

Browse files
committed
Fix build errors from libdivecomputer master merge
Three issues introduced by the merge of libdivecomputer/master: 1. parser.h: DC_SAMPLE_LOCATION was added to parsers (divesoft_freedom, divesystem_idive, halcyon_symbios, shearwater_predator) but the corresponding enum value was omitted from dc_sample_type_t. Add DC_SAMPLE_LOCATION after DC_SAMPLE_TTS and add the matching #define guard for compile-time feature testing. 2. shearwater_predator_parser.c (DC_FIELD_LOCATION case): latitude and longitude were used but never declared. The upstream version declared them as signed int inside a block; reproduce that with an explicit block scope so the variables are properly declared. 3. shearwater_petrel.c: shearwater_common_get_model() returns an unsigned int, but HEXDUMP expects const unsigned char *. Add an explicit cast to silence the incompatible-pointer-type error. Signed-off-by: Michael Keller <github@ike.ch>
1 parent acb7d69 commit 7db15b3

4 files changed

Lines changed: 39 additions & 32 deletions

File tree

include/libdivecomputer/parser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,13 @@ typedef enum dc_sample_type_t {
4848
DC_SAMPLE_DECO,
4949
DC_SAMPLE_GASMIX,
5050
DC_SAMPLE_TTS, // time to surface in seconds
51+
DC_SAMPLE_LOCATION,
5152
} dc_sample_type_t;
5253

5354
// Make it easy to test support compile-time with "#ifdef DC_SAMPLE_TTS"
5455
#define DC_SAMPLE_TTS DC_SAMPLE_TTS
56+
// Make it easy to test support compile-time with "#ifdef DC_SAMPLE_LOCATION"
57+
#define DC_SAMPLE_LOCATION DC_SAMPLE_LOCATION
5558

5659
typedef enum dc_field_type_t {
5760
DC_FIELD_DIVETIME,

src/hw_ostc3.c

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -866,18 +866,27 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi
866866
// Download the compact logbook headers. If the firmware doesn't support
867867
// compact headers yet, fallback to downloading the full logbook headers.
868868
// This is slower, but also works for older firmware versions.
869-
unsigned int compact = 1;
870-
rc = hw_ostc3_transfer (device, &progress, COMPACT,
871-
NULL, 0, header, RB_LOGBOOK_SIZE_COMPACT * RB_LOGBOOK_COUNT, NULL, NODELAY);
872-
if (rc == DC_STATUS_UNSUPPORTED) {
873-
compact = 0;
869+
// The Frog always uses the full header format.
870+
unsigned int compact = !device->frog;
871+
if (compact) {
872+
rc = hw_ostc3_transfer (device, &progress, COMPACT,
873+
NULL, 0, header, RB_LOGBOOK_SIZE_COMPACT * RB_LOGBOOK_COUNT, NULL, NODELAY);
874+
if (rc == DC_STATUS_UNSUPPORTED) {
875+
compact = 0;
876+
} else if (rc != DC_STATUS_SUCCESS) {
877+
ERROR (abstract->context, "Failed to read the header.");
878+
free (header);
879+
return rc;
880+
}
881+
}
882+
if (!compact) {
874883
rc = hw_ostc3_transfer (device, &progress, HEADER,
875884
NULL, 0, header, RB_LOGBOOK_SIZE_FULL * RB_LOGBOOK_COUNT, NULL, NODELAY);
876-
}
877-
if (rc != DC_STATUS_SUCCESS) {
878-
ERROR (abstract->context, "Failed to read the header.");
879-
free (header);
880-
return rc;
885+
if (rc != DC_STATUS_SUCCESS) {
886+
ERROR (abstract->context, "Failed to read the header.");
887+
free (header);
888+
return rc;
889+
}
881890
}
882891

883892
// Get the correct header layout.
@@ -1025,10 +1034,10 @@ hw_ostc3_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, voi
10251034

10261035
// Verify the header in the logbook and profile are identical.
10271036
if (memcmp (profile + layout->version, header + offset + logbook->version, 1) != 0 ||
1028-
compact ?
1029-
memcmp (profile + layout->fingerprint, header + offset + logbook->fingerprint, 10) != 0 ||
1030-
memcmp (profile + layout->number, header + offset + logbook->number, 2) != 0 :
1031-
memcmp (profile + layout->fingerprint, header + offset + layout->fingerprint, RB_LOGBOOK_SIZE_FULL - layout->fingerprint) != 0) {
1037+
(compact ?
1038+
(memcmp (profile + layout->fingerprint, header + offset + logbook->fingerprint, 10) != 0 ||
1039+
memcmp (profile + layout->number, header + offset + logbook->number, 2) != 0) :
1040+
memcmp (profile + layout->fingerprint, header + offset + layout->fingerprint, RB_LOGBOOK_SIZE_FULL - layout->fingerprint) != 0)) {
10321041
ERROR (abstract->context, "Unexpected profile header.");
10331042
free (profile);
10341043
free (header);

src/shearwater_petrel.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,10 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
192192

193193
unsigned int model = 0;
194194
rc = shearwater_common_get_model (&device->base, &model);
195-
if (rc != DC_STATUS_SUCCESS) {
196-
ERROR (abstract->context, "Failed to read the model number.");
195+
if (rc != DC_STATUS_SUCCESS)
197196
return rc;
198-
}
199197

200-
HEXDUMP(abstract->context, DC_LOGLEVEL_DEBUG, "Model", &model, sizeof(model));
198+
HEXDUMP(abstract->context, DC_LOGLEVEL_DEBUG, "Model", (const unsigned char *) &model, sizeof(model));
201199

202200
// Emit a device info event.
203201
dc_event_devinfo_t devinfo;
@@ -365,10 +363,8 @@ shearwater_petrel_device_timesync (dc_device_t *abstract, const dc_datetime_t *d
365363

366364
unsigned int model = 0;
367365
status = shearwater_common_get_model (device, &model);
368-
if (status != DC_STATUS_SUCCESS) {
369-
ERROR (abstract->context, "Failed to read the model number.");
366+
if (status != DC_STATUS_SUCCESS)
370367
return status;
371-
}
372368

373369
if (model == TERIC) {
374370
return shearwater_common_timesync_utc (device, datetime);

src/shearwater_predator_parser.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@
126126

127127
#define UNDEFINED 0xFFFFFFFF
128128

129-
#define GNSS_FIX_2D 2
130-
#define GNSS_FIX_3D 3
131-
132129
typedef struct shearwater_predator_parser_t shearwater_predator_parser_t;
133130

134131
typedef struct shearwater_predator_gasmix_t {
@@ -1120,15 +1117,17 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
11201117
if (parser->opening[9] == UNDEFINED || parser->aimode != AI_ON_GPS)
11211118
return DC_STATUS_UNSUPPORTED;
11221119

1123-
unsigned int gnss_status = data[parser->opening[9] + 16];
1124-
if (!(gnss_status == GNSS_FIX_2D || gnss_status == GNSS_FIX_3D))
1125-
return DC_STATUS_UNSUPPORTED;
1120+
{
1121+
unsigned int gnss_status = data[parser->opening[9] + 16];
1122+
if (!(gnss_status == GNSS_FIX_2D || gnss_status == GNSS_FIX_3D))
1123+
return DC_STATUS_UNSUPPORTED;
11261124

1127-
latitude = (signed int) array_uint32_be (data + parser->opening[9] + 21);
1128-
longitude = (signed int) array_uint32_be (data + parser->opening[9] + 25);
1129-
location->latitude = latitude / 100000.0;
1130-
location->longitude = longitude / 100000.0;
1131-
location->altitude = 0.0;
1125+
signed int latitude = (signed int) array_uint32_be (data + parser->opening[9] + 21);
1126+
signed int longitude = (signed int) array_uint32_be (data + parser->opening[9] + 25);
1127+
location->latitude = latitude / 100000.0;
1128+
location->longitude = longitude / 100000.0;
1129+
location->altitude = 0.0;
1130+
}
11321131
break;
11331132
case DC_FIELD_STRING:
11341133
return dc_field_get_string(&parser->cache, flags, string);

0 commit comments

Comments
 (0)