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>
This commit is contained in:
Linus Torvalds 2011-09-11 13:16:23 -07:00
parent 27ed16072f
commit 0282d515db

View file

@ -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 * Divinglog is crazy. The temperatures are in celsius. EXCEPT
* for the sample temperatures, that are in Fahrenheit. * for the sample temperatures, that are in Fahrenheit.
* WTF? * 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) static void fahrenheit(char *buffer, void *_temperature)
{ {
@ -496,6 +506,9 @@ static void fahrenheit(char *buffer, void *_temperature)
switch (integer_or_float(buffer, &val)) { switch (integer_or_float(buffer, &val)) {
case FLOAT: 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; temperature->mkelvin = (val.fp + 459.67) * 5000/9;
break; break;
default: default: