Skip to content

Commit affdbf8

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 affdbf8

3 files changed

Lines changed: 14 additions & 12 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: 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)