Skip to content

Commit

Permalink
[mms-settings] Accept floating point values from dconf
Browse files Browse the repository at this point in the history
In addition to all kinds of integers we will also accept a double value
as long as it falls into [0..UINT_MAX] range.
  • Loading branch information
monich committed Aug 22, 2014
1 parent cf2acb4 commit b9718b5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mms-settings-dconf/src/mms_settings_dconf.c
Expand Up @@ -104,12 +104,20 @@ mms_settings_dconf_get_uint32(
} else if (klass == G_VARIANT_CLASS_UINT64) {
guint64 u64 = g_variant_get_uint64(variant);
if (u64 <= UINT_MAX) {
*value = (guint32)u64;
*value = (unsigned int)u64;
return TRUE;
}
} else if (klass == G_VARIANT_CLASS_DOUBLE) {
gdouble d = g_variant_get_double(variant);
if (d >= 0.0 && d <= (double)UINT_MAX) {
*value = (unsigned int)d;
return TRUE;
}
} else {
MMS_ERR("Unexpected variant type \'%c\'", (char)klass);
return FALSE;
}
MMS_ERR("Unable to convert variant type \'%c\'", (char)klass);
}
return FALSE;
}
Expand Down

0 comments on commit b9718b5

Please sign in to comment.