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>
This commit is contained in:
Jeremie Guichard 2017-03-08 13:41:41 +07:00
parent 9c2619ea3b
commit 406e4287eb
21 changed files with 101 additions and 101 deletions

View file

@ -81,40 +81,40 @@ static temperature_t get_temperature(const char *line)
static depth_t get_depth(const char *line)
{
depth_t d;
d.mm = rint(1000*ascii_strtod(line, NULL));
d.mm = lrint(1000*ascii_strtod(line, NULL));
return d;
}
static volume_t get_volume(const char *line)
{
volume_t v;
v.mliter = rint(1000*ascii_strtod(line, NULL));
v.mliter = lrint(1000*ascii_strtod(line, NULL));
return v;
}
static weight_t get_weight(const char *line)
{
weight_t w;
w.grams = rint(1000*ascii_strtod(line, NULL));
w.grams = lrint(1000*ascii_strtod(line, NULL));
return w;
}
static pressure_t get_pressure(const char *line)
{
pressure_t p;
p.mbar = rint(1000*ascii_strtod(line, NULL));
p.mbar = lrint(1000*ascii_strtod(line, NULL));
return p;
}
static int get_salinity(const char *line)
{
return rint(10*ascii_strtod(line, NULL));
return lrint(10*ascii_strtod(line, NULL));
}
static fraction_t get_fraction(const char *line)
{
fraction_t f;
f.permille = rint(10*ascii_strtod(line, NULL));
f.permille = lrint(10*ascii_strtod(line, NULL));
return f;
}
@ -568,10 +568,10 @@ static char *parse_sample_unit(struct sample *sample, double val, char *unit)
/* The units are "°C", "m" or "bar", so let's just look at the first character */
switch (*unit) {
case 'm':
sample->depth.mm = rint(1000*val);
sample->depth.mm = lrint(1000*val);
break;
case 'b':
sample->cylinderpressure.mbar = rint(1000*val);
sample->cylinderpressure.mbar = lrint(1000*val);
break;
default:
sample->temperature.mkelvin = C_to_mkelvin(val);