mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 20:35:49 +01:00
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:
parent
cdbfef3842
commit
665292006e
@ -51,7 +51,7 @@ static void \
|
|||||||
value_transform_##func_name (const GValue *src_value, \
|
value_transform_##func_name (const GValue *src_value, \
|
||||||
GValue *dest_value) \
|
GValue *dest_value) \
|
||||||
{ \
|
{ \
|
||||||
ctype c_value = src_value->data[0].from_member; \
|
ctype c_value = (ctype) src_value->data[0].from_member; \
|
||||||
dest_value->data[0].to_member = c_value; \
|
dest_value->data[0].to_member = c_value; \
|
||||||
} extern void glib_dummy_decl (void)
|
} extern void glib_dummy_decl (void)
|
||||||
DEFINE_CAST (int_s8, v_int, gint8, v_int);
|
DEFINE_CAST (int_s8, v_int, gint8, v_int);
|
||||||
|
@ -190,7 +190,8 @@ value_collect_float (GValue *value,
|
|||||||
GTypeCValue *collect_values,
|
GTypeCValue *collect_values,
|
||||||
guint collect_flags)
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user