Good night again, Dirk and Miika.  Good night Guido.

2015-09-09 17:29 GMT+02:00 Miika Turkia <miika.tur...@gmail.com>:
> I am looking at ostc_prepare_data function and do not fully understand
> the code. It looks like in successful case ldc_dat memory allocation
> is freed and we end up pointing to unallocated data in our data
> structures. However, the failure case ends up leaking memory.
>
> Is the attached patch correct or am I missing something? (I have
> nothing to test the code with.)

The patch works, although it changes leak on failure with leak on success.
In fact the full ldc_dat pointer is useless and can be safely removed, it
was a remnant of initial work.  This was the reason you didn't understand
the code.
If you want to test, there are two .dive files included in dives directory.

Please, Dirk, apply the attached patch instead of Miika's one.

2015-09-09 18:54 GMT+02:00 Dirk Hohndel <d...@hohndel.org>:

> On Wed, Sep 09, 2015 at 07:48:03PM +0300, Guido Lerch wrote:
> >
> > Hi Miika
> > I might have some time to test tomorrow. I have an OSTC 3.
> > Need to figure out first how to apply the patch my testing branch,
> Google will help I suppose.
>
>
Guido, please note that this  has nothing to do with OSTC devices
downloads, it is a tool intended to import dives which have been previously
downloaded from DC using OSTCTools software.  If you want to try the
import, you have to have the .dive files made with said program.
BTW, if you have OSTCTools files of your own, you may find that some dives
from OSTC3 fail in the middle of the profile.  It is due to a problem in
some OSTC 3 firmware versions that H&W corrected some time ago.  OSTCTools
reads the full profile data, but libdivecomputer aborts as it does sanity
checks and detects inconsistent data  (e.g.  216% O2 in the mix).  The
profile needs, in these cases, to be manually fixed changing the damaged
bytes in the .dive file.


> It's pretty easy. Save the email to a file.
>
> git am < file
>
> am literally stands for "apply mail" :-)
>
>
Although Dirk knows light years more about git than I will ever do,  I have
to say that git am /path/to/file.patch  without "<"  works exactly the
same  ;-)

Regards.

Salva.
From fca19823aa4f330199e332de03c5d56c1cac0284 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= <salvador.cu...@gmail.com>
Date: Thu, 10 Sep 2015 00:06:48 +0200
Subject: [PATCH] OSTCTools - remove useless pointer ldc_dat
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This device_data_t pointer was a remnant from initial work. It is
useless and can be safely removed.

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

diff --git a/ostctools.c b/ostctools.c
index a1727ce..7b8c3c1 100644
--- a/ostctools.c
+++ b/ostctools.c
@@ -40,22 +40,18 @@ static dc_descriptor_t *ostc_get_data_descriptor(int data_model, dc_family_t dat
  */
 static int ostc_prepare_data(int data_model, dc_family_t dc_fam, device_data_t *dev_data)
 {
-	device_data_t *ldc_dat = calloc(1, sizeof(device_data_t));
 	dc_descriptor_t *data_descriptor;
 
-	*ldc_dat = *dev_data;
-	ldc_dat->device = NULL;
-	ldc_dat->context = NULL;
+	dev_data->device = NULL;
+	dev_data->context = NULL;
 
 	data_descriptor = ostc_get_data_descriptor(data_model, dc_fam);
 	if (data_descriptor) {
-		ldc_dat->descriptor = data_descriptor;
-		ldc_dat->vendor = copy_string(data_descriptor->vendor);
-		ldc_dat->model = copy_string(data_descriptor->product);
-		*dev_data = *ldc_dat;
+		dev_data->descriptor = data_descriptor;
+		dev_data->vendor = copy_string(data_descriptor->vendor);
+		dev_data->model = copy_string(data_descriptor->product);
 	} else
 		return 0;
-	free(ldc_dat);
 	return 1;
 }
 
-- 
2.5.1

_______________________________________________
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to