summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-18 14:17:31 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-04 15:14:25 -0700
commit167b41b6e54ca430788769d421639b70a30e2001 (patch)
treeed1645ad384b15e4ee0a41cb6f1517d16e1b13de /core
parent5c625d811690e9981d00c85aca6bcc6e82e79d27 (diff)
downloadsubsurface-167b41b6e54ca430788769d421639b70a30e2001.tar.gz
Cleanup: unglobalize variables in datatrak.c
It's a drop in the bucket, but let's remove some unnecessary global variables. With one exception these variables were only used in one function anyway. The other one can be passed as a parameter. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/datatrak.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/core/datatrak.c b/core/datatrak.c
index 60c47fcb7..9086f959a 100644
--- a/core/datatrak.c
+++ b/core/datatrak.c
@@ -15,12 +15,6 @@
#include "device.h"
#include "file.h"
-unsigned char tmp_1byte, *byte;
-unsigned int tmp_2bytes;
-char is_nitrox, is_O2, is_SCR;
-unsigned long tmp_4bytes;
-long maxbuf;
-
static unsigned int two_bytes_to_int(unsigned char x, unsigned char y)
{
return (x << 8) + y;
@@ -146,7 +140,7 @@ static dc_status_t dt_libdc_buffer(unsigned char *ptr, int prf_length, int dc_mo
* Parses a mem buffer extracting its data and filling a subsurface's dive structure.
* Returns a pointer to last position in buffer, or NULL on failure.
*/
-unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive)
+static unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive, long maxbuf)
{
int rc, profile_length, libdc_model;
char *tmp_notes_str = NULL;
@@ -156,13 +150,13 @@ unsigned char *dt_dive_parser(unsigned char *runner, struct dive *dt_dive)
*compl_buffer,
*membuf = runner;
char buffer[1024];
+ unsigned char tmp_1byte, *byte;
+ unsigned int tmp_2bytes;
+ unsigned long tmp_4bytes;
struct dive_site *ds;
- device_data_t *devdata = calloc(1, sizeof(device_data_t));
+ char is_nitrox = 0, is_O2 = 0, is_SCR = 0;
- /*
- * Reset global variables for new dive
- */
- is_nitrox = is_O2 = is_SCR = 0;
+ device_data_t *devdata = calloc(1, sizeof(device_data_t));
/*
* Parse byte to byte till next dive entry
@@ -581,7 +575,7 @@ int datatrak_import(struct memblock *mem, struct dive_table *table)
unsigned char *runner;
int i = 0, numdives = 0, rc = 0;
- maxbuf = (long) mem->buffer + mem->size;
+ long maxbuf = (long) mem->buffer + mem->size;
// Verify fileheader, get number of dives in datatrak divelog, zero on error
numdives = read_file_header((unsigned char *)mem->buffer);
@@ -597,7 +591,7 @@ int datatrak_import(struct memblock *mem, struct dive_table *table)
while ((i < numdives) && ((long) runner < maxbuf)) {
struct dive *ptdive = alloc_dive();
- runner = dt_dive_parser(runner, ptdive);
+ runner = dt_dive_parser(runner, ptdive, maxbuf);
if (runner == NULL) {
report_error(translate("gettextFromC", "Error: no dive"));
free(ptdive);