diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-11 13:16:23 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-09-11 15:49:50 -0700 |
commit | 0282d515db875cee0139e121db13084be0caac82 (patch) | |
tree | 8896e7723463a6f6fb1f0ec4dfab953944bc600d /parse-xml.c | |
parent | 27ed16072f3b49b07e0af495fed10f883de90c82 (diff) | |
download | subsurface-0282d515db875cee0139e121db13084be0caac82.tar.gz |
Work around more Diving Log bugs..
The Diving Log temperature reading is in Fahrenheit for the samples (for
the per-dive water/air temperature it's in Celsius). But it seems to
have a bug where a lack of a sample has been turned into 32 Fahrenheit
(which is 0 celsius). This is despite the dive itself having a water
temperature of 8 degF.
Just throw away those bogus freezing temperatures. Sure, they can
happen, and ice divers are crazy - but in this case I know it's just an
error in the log, and it looks very much like a Diving Log bug.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/parse-xml.c b/parse-xml.c index 8e64b1e21..e14d9db2b 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -488,6 +488,16 @@ static int uemis_fill_sample(struct sample *sample, const char *name, int len, c * Divinglog is crazy. The temperatures are in celsius. EXCEPT * for the sample temperatures, that are in Fahrenheit. * WTF? + * + * Oh, and I think Diving Log *internally* probably kept them + * in celsius, because I'm seeing entries like + * + * <Temp>32.0</Temp> + * + * in there. Which is freezing, aka 0 degC. I bet the "0" is + * what Diving Log uses for "no temperature". + * + * So throw away crap like that. */ static void fahrenheit(char *buffer, void *_temperature) { @@ -496,6 +506,9 @@ static void fahrenheit(char *buffer, void *_temperature) switch (integer_or_float(buffer, &val)) { case FLOAT: + /* Floating point equality is evil, but works for small integers */ + if (val.fp == 32.0) + break; temperature->mkelvin = (val.fp + 459.67) * 5000/9; break; default: |