Skip to content

Commit 6d03f62

Browse files
committed
Garmin: Remove File Name from File Data.
Remove the file name from the beginning of the file data buffer. This is in preparation to a move to shift the .FIT file importer to 'Import log files'. The file name in the buffer does not seem to be used for anything, and it seems to be wrong to have this added only for the parser to then have to remove this non-file-content again first thing. Fingerprinting has been confirmed as working after this change. Signed-off-by: Michael Keller <[email protected]>
1 parent a0684b8 commit 6d03f62

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

src/garmin.c

-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,6 @@ garmin_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void
558558

559559
// Reset the membuffer, read the data
560560
dc_buffer_clear(file);
561-
dc_buffer_append(file, name, FIT_NAME_SIZE);
562561
#ifdef HAVE_LIBMTP
563562
if (device->use_mtp)
564563
status = mtp_read_file(device, files.array[i].mtp_id, file);

src/garmin_parser.c

+13-14
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ struct field_desc {
452452
{ \
453453
char fmtbuf[FMTSIZE]; \
454454
if (strcmp(#type, base_type_info[base_type].type_name)) \
455-
fprintf(stderr, "%s: %s should be %s\n", #name, #type, base_type_info[base_type].type_name); \
455+
INFO(g->base.context, "%s: %s should be %s\n", #name, #type, base_type_info[base_type].type_name); \
456456
type val = type##_VALUE(g, p); \
457457
if (val == type##_INVAL) return; \
458458
type##_FORMAT(val, fmtbuf); \
@@ -1499,29 +1499,25 @@ traverse_data(struct garmin_parser_t *garmin)
14991499
memset(&garmin->record_data, 0, sizeof(garmin->record_data));
15001500
memset(garmin->type_desc, 0, sizeof(garmin->type_desc));
15011501

1502-
// The data starts with our filename fingerprint. Skip it.
1503-
if (len < FIT_NAME_SIZE)
1504-
return DC_STATUS_IO;
1505-
1506-
DEBUG(garmin->base.context, "file %.*s", FIT_NAME_SIZE, data);
1507-
1508-
data += FIT_NAME_SIZE;
1509-
len -= FIT_NAME_SIZE;
1510-
15111502
// The FIT header
1512-
if (len < 12)
1503+
if (len < 12) {
1504+
ERROR(garmin->base.context, " file too short for FIT header");
1505+
15131506
return DC_STATUS_IO;
1507+
}
15141508

15151509
hdrsize = data[0];
15161510
protocol = data[1];
15171511
profile = array_uint16_le(data+2); // these two fields are always little endian
15181512
datasize = array_uint32_le(data+4);
15191513
if (memcmp(data+8, ".FIT", 4)) {
1520-
DEBUG(garmin->base.context, " missing .FIT marker");
1514+
ERROR(garmin->base.context, " missing .FIT marker");
1515+
15211516
return DC_STATUS_IO;
15221517
}
15231518
if (hdrsize < 12 || datasize > len || datasize + hdrsize + 2 > len) {
1524-
DEBUG(garmin->base.context, " inconsistent size information hdrsize %d datasize %d len %d", hdrsize, datasize, len);
1519+
ERROR(garmin->base.context, " inconsistent size information hdrsize %d datasize %d len %d", hdrsize, datasize, len);
1520+
15251521
return DC_STATUS_IO;
15261522
}
15271523
garmin->dive.protocol = protocol;
@@ -1563,8 +1559,11 @@ traverse_data(struct garmin_parser_t *garmin)
15631559
DEBUG(garmin->base.context, "Regular record for type %d", record);
15641560
len = traverse_regular(garmin, data, datasize, record, &time);
15651561
}
1566-
if (len <= 0 || len > datasize)
1562+
if (len <= 0 || len > datasize) {
1563+
ERROR(garmin->base.context, " traverse failed");
1564+
15671565
return DC_STATUS_IO;
1566+
}
15681567
data += len;
15691568
datasize -= len;
15701569

0 commit comments

Comments
 (0)