[PATCH 6/6] Do not set the water salinity of a dive unless libdivecomputer supports it
Linus Torvalds
torvalds at linux-foundation.org
Sun Nov 25 12:01:17 PST 2012
From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sun, 25 Nov 2012 11:44:05 -0800
Subject: [PATCH 6/6] Do not set the water salinity of a dive unless libdivecomputer supports it
It's annoying to see water salinity data in the XML that isn't relevant,
and adding the default value just because the dive got downloaded from
libdivecomputer is definitely wrong.
We should set the water salinity explicitly only if we have it
explicitly set on the dive computer.
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---
Ugh. I *despise* seeing random non-valid data show up in the XML file. We
should *not* set and save some water salinity field unless we have good
reason to actually believe that it is *explicitly* set by the user.
So defaulting to salt water (1.03% specific weight salinity) is fine, but
we sure as hell shouldn't save that kind of random default in our data
structures.
This is still wrong for the case of a libdivecomputer that actually has
salinity interfaces but just returns the default value, but at least it
doesn't generate the garbage for my setup any more.
libdivecomputer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 3325c68ffbb6..164b3a30f3b0 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -332,17 +332,17 @@ static int dive_cb(const unsigned char *data, unsigned int size,
return rc;
}
+#ifdef DC_FIELD_SALINITY
// Check if the libdivecomputer version already supports salinity
double salinity = 1.03;
-#ifdef DC_FIELD_SALINITY
rc = dc_parser_get_field(parser, DC_FIELD_SALINITY, 0, &salinity);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
dev_info(devdata, _("Error obtaining water salinity"));
dc_parser_destroy(parser);
return rc;
}
-#endif
dive->salinity = salinity * 10000.0 + 0.5;
+#endif
rc = parse_gasmixes(devdata, dive, parser, ngases);
if (rc != DC_STATUS_SUCCESS) {
--
1.8.0.dirty
More information about the subsurface
mailing list