aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Guido Lerch <guido.lerch@gmail.com>2015-09-05 11:00:54 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-05 11:27:50 -0700
commit8647f959534396e1ee6d0685908ba9801afb646b (patch)
tree1381fa98b2c1150e97aac5507bbe259ccb26a233
parenta547ee0ff2044637d2cf300655b509616b49bac1 (diff)
downloadsubsurface-8647f959534396e1ee6d0685908ba9801afb646b.tar.gz
Uemis downloader: fix and move helper function
This function is only used in the Uemis downloader, and it got broken when we switched to using a separate table for the downloaded dives. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.h15
-rw-r--r--uemis-downloader.c11
2 files changed, 10 insertions, 16 deletions
diff --git a/dive.h b/dive.h
index eac6e724d..c20b59bd3 100644
--- a/dive.h
+++ b/dive.h
@@ -582,21 +582,6 @@ extern void delete_current_divecomputer(void);
#define for_each_gps_location(_i, _x) \
for ((_i) = 0; ((_x) = get_gps_location(_i, &gps_location_table)) != NULL; (_i)++)
-static inline struct dive *get_dive_by_uemis_diveid(uint32_t diveid, uint32_t deviceid)
-{
- int i;
- struct dive *dive;
-
- for_each_dive (i, dive) {
- struct divecomputer *dc = &dive->dc;
- do {
- if (dc->diveid == diveid && dc->deviceid == deviceid)
- return dive;
- } while ((dc = dc->next) != NULL);
- }
- return NULL;
-}
-
static inline struct dive *get_dive_by_uniq_id(int id)
{
int i;
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 8c912d4cf..340daee60 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -126,6 +126,15 @@ static struct dive *uemis_start_dive(uint32_t deviceid)
return dive;
}
+static struct dive *get_dive_by_uemis_diveid(device_data_t *devdata, u_int32_t object_id)
+{
+ for (int i = 0; i < devdata->download_table->nr; i++) {
+ if (object_id == devdata->download_table->dives[i]->dc.diveid)
+ return devdata->download_table->dives[i];
+ }
+ return NULL;
+}
+
static void record_uemis_dive(device_data_t *devdata, struct dive *dive)
{
if (devdata->create_new_trip) {
@@ -817,7 +826,7 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
dive->number = atoi(val);
} else if (!log && !strcmp(tag, "logfilenr")) {
/* this one tells us which dive we are adding data to */
- dive = get_dive_by_uemis_diveid(atoi(val), deviceid);
+ dive = get_dive_by_uemis_diveid(devdata, atoi(val));
if (for_dive)
*for_dive = atoi(val);
} else if (!log && dive && !strcmp(tag, "divespot_id")) {