GNOME Bugzilla – Bug 678333
gdbus-codegen code causes warnings under -Wfloat-equal
Last modified: 2012-06-20 12:21:30 UTC
gdbus-codegen's generated code includes: case G_TYPE_DOUBLE: ret = (g_value_get_double (a) == g_value_get_double (b)); break; Under -Wfloat-equal, this causes a warning (and NetworkManager builds with both -Wfloat-equal and -Werror). Possible fixes: 1. Move _g_value_equal() into libgio or libgobject so it always gets compiled against glib's warning flags and we don't have to worry about it. 2. gdouble da = g_value_get_double (a); gdouble db = g_value_get_double (b); ret = !memcmp (&da, &db, sizeof (gdouble)); 3. Copy code from G_GNUC_BEGIN_IGNORE_DEPRECATIONS: #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) _Pragma ("GCC diagnostic push") _Pragma ("GCC diagnostic ignored \"-Wfloat-equal\"") #endif ret = (g_value_get_double (a) == g_value_get_double (b)); #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) _Pragma ("GCC diagnostic pop") #endif
Oh, wicked! I think I'd prefer option 2, but with explicit test again the value 0 instead of using the ! operator (just to follow the existing coding style in the codegen)...
Created attachment 216696 [details] [review] gdbus: fix generated code to not warn under -Wfloat-equal FIXME: the test case doesn't actually work, because GObject emits a notify:: even though the generated code doesn't. We'd have to assert the proxy never receives the notification, but the existing code seems to assume that we can't practically bound the amount of time it will take for the proxy to receive a property change notification, so this would have to be racy depending on the machine's load...
Created attachment 216757 [details] [review] gdbus: fix generated code to not warn under -Wfloat-equal
Looks good to me - thanks for adding the test!
Attachment 216757 [details] pushed as 7d0db04 - gdbus: fix generated code to not warn under -Wfloat-equal