mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
uemis: code refactoring
- Variable max_deleted_seen had no effect and is removed. - Results of read/write operations are evaluated to assert success and to prevent compiler warnings. Signed-off-by: Oliver Schwaneberg <oliver.schwaneberg@gmail.com>
This commit is contained in:
parent
8f81a22e7f
commit
728e007c5c
1 changed files with 7 additions and 13 deletions
|
@ -75,8 +75,6 @@ static int next_table_index = 0;
|
||||||
static int dive_to_read = 0;
|
static int dive_to_read = 0;
|
||||||
static uint32_t mindiveid;
|
static uint32_t mindiveid;
|
||||||
|
|
||||||
static int max_deleted_seen = -1;
|
|
||||||
|
|
||||||
/* Linked list to remember already executed divespot download requests */
|
/* Linked list to remember already executed divespot download requests */
|
||||||
struct divespot_mapping {
|
struct divespot_mapping {
|
||||||
int divespot_id;
|
int divespot_id;
|
||||||
|
@ -317,7 +315,8 @@ static bool uemis_init(const char *path)
|
||||||
}
|
}
|
||||||
if (bytes_available(reqtxt_file) > 5) {
|
if (bytes_available(reqtxt_file) > 5) {
|
||||||
char tmp[6];
|
char tmp[6];
|
||||||
read(reqtxt_file, tmp, 5);
|
if (read(reqtxt_file, tmp, 5) != 5)
|
||||||
|
return false;
|
||||||
tmp[5] = '\0';
|
tmp[5] = '\0';
|
||||||
#if UEMIS_DEBUG & 2
|
#if UEMIS_DEBUG & 2
|
||||||
fprintf(debugfile, "::r req.txt \"%s\"\n", tmp);
|
fprintf(debugfile, "::r req.txt \"%s\"\n", tmp);
|
||||||
|
@ -594,7 +593,8 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
read(ans_file, tmp, 100);
|
if (read(ans_file, tmp, 100) < 0)
|
||||||
|
return false;
|
||||||
close(ans_file);
|
close(ans_file);
|
||||||
#if UEMIS_DEBUG & 8
|
#if UEMIS_DEBUG & 8
|
||||||
tmp[100] = '\0';
|
tmp[100] = '\0';
|
||||||
|
@ -1065,12 +1065,6 @@ static char *uemis_get_divenr(char *deviceidstr, int force)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
snprintf(divenr, 10, "%d", maxdiveid);
|
snprintf(divenr, 10, "%d", maxdiveid);
|
||||||
return strdup(divenr);
|
return strdup(divenr);
|
||||||
}
|
}
|
||||||
|
@ -1082,6 +1076,7 @@ static bool do_dump_buffer_to_file(char *buf, char *prefix)
|
||||||
char path[100];
|
char path[100];
|
||||||
char date[40];
|
char date[40];
|
||||||
char obid[40];
|
char obid[40];
|
||||||
|
bool success;
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1106,10 +1101,10 @@ static bool do_dump_buffer_to_file(char *buf, char *prefix)
|
||||||
int dumpFile = subsurface_open(path, O_RDWR | O_CREAT, 0666);
|
int dumpFile = subsurface_open(path, O_RDWR | O_CREAT, 0666);
|
||||||
if (dumpFile == -1)
|
if (dumpFile == -1)
|
||||||
return false;
|
return false;
|
||||||
write(dumpFile, buf, strlen(buf));
|
success = write(dumpFile, buf, strlen(buf)) == strlen(buf);
|
||||||
close(dumpFile);
|
close(dumpFile);
|
||||||
bufCnt++;
|
bufCnt++;
|
||||||
return true;
|
return success;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1269,7 +1264,6 @@ static bool get_matching_dive(int idx, char *newmax, int *uemis_mem_status, devi
|
||||||
fprintf(debugfile, "TRY matching dive log id %d from %s with dive details %d but details are deleted\n", dive->dc.diveid, d_time, dive_to_read);
|
fprintf(debugfile, "TRY matching dive log id %d from %s with dive details %d but details are deleted\n", dive->dc.diveid, d_time, dive_to_read);
|
||||||
#endif
|
#endif
|
||||||
deleted_files++;
|
deleted_files++;
|
||||||
max_deleted_seen = dive_to_read;
|
|
||||||
/* mark this log entry as deleted and cleanup later, otherwise we mess up our array */
|
/* mark this log entry as deleted and cleanup later, otherwise we mess up our array */
|
||||||
dive->downloaded = false;
|
dive->downloaded = false;
|
||||||
#if UEMIS_DEBUG & 2
|
#if UEMIS_DEBUG & 2
|
||||||
|
|
Loading…
Add table
Reference in a new issue