9 Commits

Author SHA1 Message Date
Dirk Hohndel
eaeb5c5341 cleanup: ensure mtp_device field is 0
We explicitly check that field for 0 before dereferencing it. Let's make sure
that it always starts out being 0 - otherwise we'll get a potential crash here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-07-12 14:49:13 -07:00
Dirk Hohndel
4fc85409da bugfix: only sort non-NULL array
Unclear if this is needed.

This might address CID 363698

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-31 15:10:25 -07:00
Dirk Hohndel
47be86eb79 fix incorrect comparison
Operator precedence gets me every time. Equally binds stronger
than bitwise logical operation.

Fixes CID 363699

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-31 15:09:04 -07:00
Dirk Hohndel
9554e87431 Garmin: support .FIT files from filesystem even for MTP devices
If the caller provides us with a path name, we should not try to connect to the
dive computer via MTP, but instead read the .FIT files from the path provided.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-30 10:01:29 -07:00
Dirk Hohndel
ea3e542450 Garmin: add MTP support
Create parallel helper functions that use libmtp to walk the file tree on the
device and to then read a specific file from the device into our dc_buffer.
MTP is not a file system, it's an object storage, that just happens to allow
object names and parent/child relationships between objects. As a result we
need to remember those file ids for MTP downloads.

The mtp_get_file_list function is rather complex as it includes both the
initial communication with the device and the code to walk the object tree and
then create the list of file.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-29 13:48:01 -07:00
Dirk Hohndel
05e066b2ff Garmin: refactor the code to prepare for MTP support
Breaking things into helper function makes it much easier to then support both
regular file operations and MTP.

This includes some mild whitespace cleanups for consistency.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-29 13:21:10 -07:00
Dirk Hohndel
e1bbdd5e65 Garmin: pass the model to the device_open function
We do this for a few other device where we need slightly different behavior,
depending on the specific model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-10-27 15:26:20 -07:00
Dirk Hohndel
a004fdffed fix some coverity errors
CID 350142: Resource leak
CID 350154: Resource leak
CID 360641: Resource leak
CID 350147: Possibly not null-terminated strings

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2020-09-21 12:05:57 -07:00
Linus Torvalds
4e9e94d9f8 Add backend for Garmin Descent Mk1
This uses pretty much all of our new infrastructure: the USB storage
iostream for the actual IO, the field-cache for the divecomputer fields,
and the string interface for the events.

It's also a very fast downloader.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00