Skip to content

Commit cb34af2

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 cb34af2

3 files changed

Lines changed: 15 additions & 10 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/shearwater_petrel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ shearwater_petrel_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
197197
return rc;
198198
}
199199

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

202202
// Emit a device info event.
203203
dc_event_devinfo_t devinfo;

src/shearwater_predator_parser.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,17 @@ shearwater_predator_parser_get_field (dc_parser_t *abstract, dc_field_type_t typ
11201120
if (parser->opening[9] == UNDEFINED || parser->aimode != AI_ON_GPS)
11211121
return DC_STATUS_UNSUPPORTED;
11221122

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;
1126-
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;
1123+
{
1124+
unsigned int gnss_status = data[parser->opening[9] + 16];
1125+
if (!(gnss_status == GNSS_FIX_2D || gnss_status == GNSS_FIX_3D))
1126+
return DC_STATUS_UNSUPPORTED;
1127+
1128+
signed int latitude = (signed int) array_uint32_be (data + parser->opening[9] + 21);
1129+
signed int longitude = (signed int) array_uint32_be (data + parser->opening[9] + 25);
1130+
location->latitude = latitude / 100000.0;
1131+
location->longitude = longitude / 100000.0;
1132+
location->altitude = 0.0;
1133+
}
11321134
break;
11331135
case DC_FIELD_STRING:
11341136
return dc_field_get_string(&parser->cache, flags, string);

0 commit comments

Comments
 (0)