summaryrefslogtreecommitdiffstats
path: root/core/liquivision.c
diff options
context:
space:
mode:
authorGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-09 23:07:30 +0700
committerGravatar Jeremie Guichard <djebrest@gmail.com>2017-03-09 23:07:30 +0700
commit2b06a0b2234cf2779f80e87038011067be282bcb (patch)
tree7532b11736a5eaedb3ceddf3e85ee423948d47ce /core/liquivision.c
parent406e4287eb96e10ddfd22163f0e863e353470c68 (diff)
downloadsubsurface-2b06a0b2234cf2779f80e87038011067be282bcb.tar.gz
Fix potential double/float to int rounding errors
Not using lrint(f) when converting double/float to int creates rounding errors. This error was detected by TestParse::testParseDM4 failure on Windows. It was creating rounding inconsistencies on Linux too, see change in TestDiveDM4.xml. Enable -Wfloat-conversion for gcc version greater than 4.9.0 Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'core/liquivision.c')
-rw-r--r--core/liquivision.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/liquivision.c b/core/liquivision.c
index 9347a724a..e2e9ff75e 100644
--- a/core/liquivision.c
+++ b/core/liquivision.c
@@ -234,9 +234,9 @@ static void parse_dives (int log_version, const unsigned char *buf, unsigned int
// Xeo, with CNS and OTU
start_cns = *(float *) (buf + ptr);
ptr += 4;
- dive->cns = *(float *) (buf + ptr); // end cns
+ dive->cns = lrintf(*(float *) (buf + ptr)); // end cns
ptr += 4;
- dive->otu = *(float *) (buf + ptr);
+ dive->otu = lrintf(*(float *) (buf + ptr));
ptr += 4;
dive_mode = *(buf + ptr++); // 0=Deco, 1=Gauge, 2=None
algorithm = *(buf + ptr++); // 0=ZH-L16C+GF