[PATCH] OSTCTools - Add unsigned char variable

Salvador Cuñat salvador.cunat at gmail.com
Mon Jul 6 13:02:03 PDT 2015


In commit 22bfc49 an explicit cast to (char *) was introduced to silence
some compiler warnings, but an (unsigned char *) is needed if related
values are expected to be greater than 127 or we will get the usual
weirdnesses.

Just introduce such variable and use it where needed.

Signed-off-by: Salvador Cuñat <salvador.cunat at gmail.com>
---
 ostctools.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/ostctools.c b/ostctools.c
index 84af67d..45a21e9 100644
--- a/ostctools.c
+++ b/ostctools.c
@@ -67,7 +67,7 @@ void ostctools_import(const char *file, struct dive_table *divetable)
 	FILE *archive;
 	device_data_t *devdata = calloc(1, sizeof(device_data_t));
 	dc_family_t dc_fam;
-	unsigned char *buffer = calloc(65536, 1);
+	unsigned char *buffer = calloc(65536, 1), *uc_tmp;
 	char *tmp;
 	struct dive *ostcdive = alloc_dive();
 	dc_status_t rc = 0;
@@ -85,18 +85,18 @@ void ostctools_import(const char *file, struct dive_table *divetable)
 	}
 
 	// Read dive number from the log
-	tmp =  calloc(2,1);
+	uc_tmp =  calloc(2, 1);
 	fseek(archive, 258, 0);
-	fread(tmp, 1, 2, archive);
-	ostcdive->number = tmp[0] + (tmp[1] << 8);
-	free(tmp);
+	fread(uc_tmp, 1, 2, archive);
+	ostcdive->number = uc_tmp[0] + (uc_tmp[1] << 8);
+	free(uc_tmp);
 
 	// Read device's serial number
-	tmp = calloc(2, 1);
+	uc_tmp = calloc(2, 1);
 	fseek(archive, 265, 0);
-	fread(tmp, 1, 2, archive);
-	serial = tmp[0] + (tmp[1] << 8);
-	free(tmp);
+	fread(uc_tmp, 1, 2, archive);
+	serial = uc_tmp[0] + (uc_tmp[1] << 8);
+	free(uc_tmp);
 
 	// Read dive's raw data, header + profile
 	fseek(archive, 456, 0);
-- 
2.1.4



More information about the subsurface mailing list