From: Linus Torvalds Date: Thu, 1 Sep 2011 20:46:24 +0000 (-0700) Subject: libdivecomputer does crazy gas mixes too X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=adc7280c025e68f6d55d779ad56712cb17aa3ae7;p=ext%2Fsubsurface.git libdivecomputer does crazy gas mixes too Did I just say "In comparison, the libdivecomputer output is nice and sane"? It turns out that libdivecomputer has been doing some drugs too when it comes to gas mixes. Like showing O2 percentages as 255.0% and N2 percentages as -155.0%. Clearly libdivecomputer uses a 'unsigned char' for oxygen percentage, and makes "-1" be "undefined". And then it prints that non-existing mix out, and in the process does MATH on the damn thing ("100-O2") to "calculate" the nitrogen percentage. Christ. Just make the parser silently ignore the craziness, because printing out "Strange percentage reading -155.0" a few hundred times just doesn't make anything any better. Signed-off-by: Linus Torvalds --- diff --git a/parse-xml.c b/parse-xml.c index 892e0fb..e0231ce 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -326,6 +326,9 @@ static void percent(char *buffer, void *_fraction) static void gasmix(char *buffer, void *_fraction) { + /* libdivecomputer does negative percentages. */ + if (*buffer == '-') + return; if (gasmix_index < MAX_MIXES) percent(buffer, _fraction); }