From 0282d515db875cee0139e121db13084be0caac82 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 11 Sep 2011 13:16:23 -0700 Subject: [PATCH] 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 --- parse-xml.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/parse-xml.c b/parse-xml.c index 8e64b1e..e14d9db 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 + * + * 32.0 + * + * 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: -- 2.43.0