summaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-09 19:06:14 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-09 21:47:36 -0800
commitae5c7a55be062d3113c9e4f24b476bdba82e8d33 (patch)
tree4c6595d930ca41280926dba07e38857c38b0280a /subsurface-core
parent349c27a96eb2731a697da5b4a50fe6c9ca7a0dd0 (diff)
downloadsubsurface-ae5c7a55be062d3113c9e4f24b476bdba82e8d33.tar.gz
Clean up UEMIS downloader
Mostly signedness issues, but also removing useless code that didn't have any effect. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-rw-r--r--subsurface-core/uemis-downloader.c18
-rw-r--r--subsurface-core/uemis.c6
-rw-r--r--subsurface-core/uemis.h2
3 files changed, 12 insertions, 14 deletions
diff --git a/subsurface-core/uemis-downloader.c b/subsurface-core/uemis-downloader.c
index 6f5c5f177..b9b532303 100644
--- a/subsurface-core/uemis-downloader.c
+++ b/subsurface-core/uemis-downloader.c
@@ -506,7 +506,8 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
#if UEMIS_DEBUG & 4
fprintf(debugfile, "::w req.txt \"%s\"\n", sb);
#endif
- if (write(reqtxt_file, sb, strlen(sb)) != strlen(sb)) {
+ int written = write(reqtxt_file, sb, strlen(sb));
+ if (written == -1 || (size_t)written != strlen(sb)) {
*error_text = translate("gettextFromC", ERR_FS_SHORT_WRITE);
return false;
}
@@ -784,7 +785,7 @@ static bool uemis_delete_dive(device_data_t *devdata, uint32_t diveid)
* index into yet another data store that we read out later. In order to
* correctly populate the location and gps data from that we need to remember
* the addresses of those fields for every dive that references the divespot. */
-static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *inbuf, char **max_divenr, bool keep_number, int *for_dive)
+static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *inbuf, char **max_divenr, int *for_dive)
{
char *buf = strdup(inbuf);
char *tp, *bp, *tag, *type, *val;
@@ -793,7 +794,7 @@ static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char *
char *endptr = buf + inbuflen;
bool is_log = false, is_dive = false;
char *sections[10];
- int s, nr_sections = 0;
+ size_t s, nr_sections = 0;
struct dive *dive = NULL;
char dive_no[10];
@@ -974,7 +975,7 @@ static char *uemis_get_divenr(char *deviceidstr, int force)
maxdiveid = dc->diveid;
}
}
- if (max_deleted_seen >= 0 && maxdiveid < max_deleted_seen) {
+ if (max_deleted_seen >= 0 && maxdiveid < (uint32_t)max_deleted_seen) {
maxdiveid = max_deleted_seen;
#if UEMIS_DEBUG & 4
fprintf(debugfile, "overriding max seen with max deleted seen %d\n", max_deleted_seen);
@@ -1154,7 +1155,7 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, stru
* we mark the search successful even if the dive has been deleted. */
found = true;
if (strstr(mbuf, "deleted{bool{true") == NULL) {
- process_raw_buffer(data, deviceidnr, mbuf, &newmax, false, NULL);
+ process_raw_buffer(data, deviceidnr, mbuf, &newmax, NULL);
/* remember the last log file number as it is very likely that subsequent dives
* have the same or higher logfile number.
* UEMIS unfortunately deletes dives by deleting the dive details and not the logs. */
@@ -1223,7 +1224,7 @@ const char *do_uemis_import(device_data_t *data)
char *deviceid = NULL;
const char *result = NULL;
char *endptr;
- bool success, keep_number = false, once = true;
+ bool success, once = true;
int match_dive_and_log = 0;
int uemis_mem_status = UEMIS_MEM_OK;
@@ -1231,9 +1232,6 @@ const char *do_uemis_import(device_data_t *data)
home = getenv("HOME");
user = getenv("LOGNAME");
#endif
- if (dive_table.nr == 0)
- keep_number = true;
-
uemis_info(translate("gettextFromC", "Initialise communication"));
if (!uemis_init(mountpath)) {
free(reqtxt_path);
@@ -1287,7 +1285,7 @@ const char *do_uemis_import(device_data_t *data)
do_dump_buffer_to_file(realmbuf, "Divelogs");
#endif
/* process the buffer we have assembled */
- if (!process_raw_buffer(data, deviceidnr, realmbuf, &newmax, keep_number, NULL)) {
+ if (!process_raw_buffer(data, deviceidnr, realmbuf, &newmax, NULL)) {
/* if no dives were downloaded, mark end appropriately */
if (end == -2)
end = start - 1;
diff --git a/subsurface-core/uemis.c b/subsurface-core/uemis.c
index 4135e0cfe..5635d5630 100644
--- a/subsurface-core/uemis.c
+++ b/subsurface-core/uemis.c
@@ -98,7 +98,7 @@ static int uemis_convert_base64(char *base64, uint8_t **data)
}
struct uemis_helper {
- int diveid;
+ uint32_t diveid;
int lbs;
int divespot;
int dive_site_uuid;
@@ -106,7 +106,7 @@ struct uemis_helper {
};
static struct uemis_helper *uemis_helper = NULL;
-static struct uemis_helper *uemis_get_helper(int diveid)
+static struct uemis_helper *uemis_get_helper(uint32_t diveid)
{
struct uemis_helper **php = &uemis_helper;
struct uemis_helper *hp = *php;
@@ -134,7 +134,7 @@ static void uemis_weight_unit(int diveid, int lbs)
hp->lbs = lbs;
}
-int uemis_get_weight_unit(int diveid)
+int uemis_get_weight_unit(uint32_t diveid)
{
struct uemis_helper *hp = uemis_helper;
while (hp) {
diff --git a/subsurface-core/uemis.h b/subsurface-core/uemis.h
index 5f32fe76c..1758b4b32 100644
--- a/subsurface-core/uemis.h
+++ b/subsurface-core/uemis.h
@@ -13,7 +13,7 @@ extern "C" {
#endif
void uemis_parse_divelog_binary(char *base64, void *divep);
-int uemis_get_weight_unit(int diveid);
+int uemis_get_weight_unit(uint32_t diveid);
void uemis_mark_divelocation(int diveid, int divespot, uint32_t dive_site_uuid);
void uemis_set_divelocation(int divespot, char *text, double longitude, double latitude);
int uemis_get_divespot_id_by_diveid(uint32_t diveid);