gvalue: Add explicit casts in numeric transform functions

Compiling with `-Wfloat-conversion` warns about a few implicit
conversions from `double`/`float` to other numeric types in the `GValue`
transform functions.

These warnings are correct: value transformations can result in loss of
precision. That loss of precision is understood and expected, so add
some explicit casts to squash the warnings.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3405
This commit is contained in:
Philip Withnall
2024-06-28 14:35:57 +01:00
parent cdbfef3842
commit 665292006e
2 changed files with 3 additions and 2 deletions

View File

@@ -190,7 +190,8 @@ value_collect_float (GValue *value,
GTypeCValue *collect_values,
guint collect_flags)
{
value->data[0].v_float = collect_values[0].v_double;
/* This necessarily loses precision */
value->data[0].v_float = (gfloat) collect_values[0].v_double;
return NULL;
}