summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-04 11:48:40 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-05 04:07:22 +0300
commit8a1839610458ea788304f700886d54af680d6e53 (patch)
treeabc7b80ef72566e02ef035c7f08e1cfba3a8f300 /core
parent5a787305612c18ee9a442e4dd6067d3c35f05f87 (diff)
downloadsubsurface-8a1839610458ea788304f700886d54af680d6e53.tar.gz
Cleanup: don't access downloadTable directly in Uemis-downloader
The Uemis downloader determines the dive-number to be downloaded by either checking the download-table [interrupted connection] or the global dive table [fresh download]. The downloadTable is passed in the device data structure, but in the function to determine the latest dive, the global downloadTable is accessed directly [thus supposing that this table was passed in device data]. Instead, use the table from device data to avoid funny surprises should we change to a non-global download table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/uemis-downloader.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index b5969f2cc..129a48373 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -1029,12 +1029,11 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
return true;
}
-static char *uemis_get_divenr(char *deviceidstr, int force)
+static char *uemis_get_divenr(char *deviceidstr, struct dive_table *table, int force)
{
uint32_t deviceid, maxdiveid = 0;
int i;
char divenr[10];
- struct dive_table *table;
deviceid = atoi(deviceidstr);
mindiveid = 0xFFFFFFFF;
@@ -1044,11 +1043,11 @@ static char *uemis_get_divenr(char *deviceidstr, int force)
* already have.
*
* Also, if "force_download" is true, do this even if we
- * don't have any dives (maxdiveid will remain zero)
+ * don't have any dives (maxdiveid will remain ~0).
+ *
+ * Otherwise, use the global dive table.
*/
- if (force || downloadTable.nr)
- table = &downloadTable;
- else
+ if (!force && !table->nr)
table = &dive_table;
for (i = 0; i < table->nr; i++) {
@@ -1350,7 +1349,7 @@ const char *do_uemis_import(device_data_t *data)
goto bail;
param_buff[1] = "notempty";
- newmax = uemis_get_divenr(deviceid, force_download);
+ newmax = uemis_get_divenr(deviceid, data->download_table, force_download);
if (verbose)
fprintf(stderr, "Uemis downloader: start looking at dive nr %s\n", newmax);