summaryrefslogtreecommitdiffstats
path: root/core/uemis.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/uemis.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/uemis.c')
-rw-r--r--core/uemis.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/core/uemis.c b/core/uemis.c
index 564e7dfbb..199b69fa1 100644
--- a/core/uemis.c
+++ b/core/uemis.c
@@ -173,8 +173,8 @@ void uemis_set_divelocation(int divespot, char *text, double longitude, double l
struct dive_site *ds = get_dive_site_by_uuid(hp->dive_site_uuid);
if (ds) {
ds->name = strdup(text);
- ds->longitude.udeg = round(longitude * 1000000);
- ds->latitude.udeg = round(latitude * 1000000);
+ ds->longitude.udeg = lrint(longitude * 1000000);
+ ds->latitude.udeg = lrint(latitude * 1000000);
}
}
hp = hp->next;
@@ -329,7 +329,7 @@ void uemis_parse_divelog_binary(char *base64, void *datap)
if (template == 0)
template = 1;
for (i = 0; i < template; i++) {
- float volume = *(float *)(data + 116 + 25 * (gasoffset + i)) * 1000.0;
+ float volume = *(float *)(data + 116 + 25 * (gasoffset + i)) * 1000.0f;
/* uemis always assumes a working pressure of 202.6bar (!?!?) - I first thought
* it was 3000psi, but testing against all my dives gets me that strange number.
* Still, that's of course completely bogus and shows they don't get how