diff options
author | Jeremie Guichard <djebrest@gmail.com> | 2017-03-08 13:41:41 +0700 |
---|---|---|
committer | Jeremie Guichard <djebrest@gmail.com> | 2017-03-08 14:04:17 +0700 |
commit | 406e4287eb96e10ddfd22163f0e863e353470c68 (patch) | |
tree | 1a859821cdd37485b7d9ce4c0404f73fdf68e78b /core/parse-xml.c | |
parent | 9c2619ea3bcf8a0ad40a758692c26a5aec350c7f (diff) | |
download | subsurface-406e4287eb96e10ddfd22163f0e863e353470c68.tar.gz |
Change calls to rint into lrint avoiding conversion warnings
Using gcc option "-Wfloat-conversion" is useful to catch
potential conversion errors (where lrint should be used).
rint returns double and still raises the same warning,
this is why this change updates all rint calls to lrint.
In few places, where input type is a float, corresponding
lrinf is used.
Signed-off-by: Jeremie Guichard <djebrest@gmail.com>
Diffstat (limited to 'core/parse-xml.c')
-rw-r--r-- | core/parse-xml.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c index 0032a5c32..23dc76715 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -286,7 +286,7 @@ static enum number_type parse_float(const char *buffer, double *res, const char if (errno || *endp == buffer) return NEITHER; if (**endp == ',') { - if (IS_FP_SAME(val, rint(val))) { + if (IS_FP_SAME(val, lrint(val))) { /* we really want to send an error if this is a Subsurface native file * as this is likely indication of a bug - but right now we don't have * that information available */ @@ -338,7 +338,7 @@ static void pressure(char *buffer, pressure_t *pressure) break; } if (fabs(mbar) > 5 && fabs(mbar) < 5000000) { - pressure->mbar = rint(mbar); + pressure->mbar = lrint(mbar); break; } /* fallthrough */ @@ -358,7 +358,7 @@ static void salinity(char *buffer, int *salinity) union int_or_float val; switch (integer_or_float(buffer, &val)) { case FLOAT: - *salinity = rint(val.fp * 10.0); + *salinity = lrint(val.fp * 10.0); break; default: printf("Strange salinity reading %s\n", buffer); @@ -373,7 +373,7 @@ static void depth(char *buffer, depth_t *depth) case FLOAT: switch (xml_parsing_units.length) { case METERS: - depth->mm = rint(val.fp * 1000); + depth->mm = lrint(val.fp * 1000); break; case FEET: depth->mm = feet_to_mm(val.fp); @@ -405,7 +405,7 @@ static void weight(char *buffer, weight_t *weight) case FLOAT: switch (xml_parsing_units.weight) { case KG: - weight->grams = rint(val.fp * 1000); + weight->grams = lrint(val.fp * 1000); break; case LBS: weight->grams = lbs_to_grams(val.fp); @@ -510,7 +510,7 @@ static void percent(char *buffer, fraction_t *fraction) /* Then turn percent into our integer permille format */ if (val >= 0 && val <= 100.0) { - fraction->permille = rint(val * 10); + fraction->permille = lrint(val * 10); break; } default: @@ -541,7 +541,7 @@ static void cylindersize(char *buffer, volume_t *volume) switch (integer_or_float(buffer, &val)) { case FLOAT: - volume->mliter = rint(val.fp * 1000); + volume->mliter = lrint(val.fp * 1000); break; default: @@ -614,7 +614,7 @@ static void get_rating(char *buffer, int *i) static void double_to_o2pressure(char *buffer, o2pressure_t *i) { - i->mbar = rint(ascii_strtod(buffer, NULL) * 1000.0); + i->mbar = lrint(ascii_strtod(buffer, NULL) * 1000.0); } static void hex_value(char *buffer, uint32_t *i) @@ -697,7 +697,7 @@ static void psi_or_bar(char *buffer, pressure_t *pressure) if (val.fp > 400) pressure->mbar = psi_to_mbar(val.fp); else - pressure->mbar = rint(val.fp * 1000); + pressure->mbar = lrint(val.fp * 1000); break; default: fprintf(stderr, "Crazy Diving Log PSI reading %s\n", buffer); @@ -3182,7 +3182,7 @@ extern int divinglog_profile(void *handle, int columns, char **data, char **colu if (atoi(ppo2_3) > 0) cur_sample->o2sensor[2].mbar = atoi(ppo2_3) * 100; if (atoi(cns) > 0) - cur_sample->cns = rint(atoi(cns) / 10); + cur_sample->cns = lrintf(atoi(cns) / 10.0f); if (atoi(setpoint) > 0) cur_sample->setpoint.mbar = atoi(setpoint) * 100; |