[network-manager-applet] gconf-helpers: work around possible compiler bug with GValueArray deprecation workarounds
- From: Jiří Klimeš <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] gconf-helpers: work around possible compiler bug with GValueArray deprecation workarounds
- Date: Tue, 26 Mar 2013 14:44:25 +0000 (UTC)
commit 58c3bde6c88e0d3d8dfa3f8ac0c8b989f2f408dd
Author: Jiří Klimeš <jklimes redhat com>
Date: Tue Mar 26 15:36:31 2013 +0100
gconf-helpers: work around possible compiler bug with GValueArray deprecation workarounds
GValueArray is deprecated. Unfortunately, it's part of our API right now,
so we have to keep it around for a while. But since it's deprecated, and
we want to know about *other* deprecations, we have to suppress deprecations
about GValueArray. Unfortunately using macros to do that (eg in
nm-gvaluearray-compat.h) exposes some compiler bugs due to the combination
of parentheses/braces and #pragma from G_GNUC_BEGIN_IGNORE_DEPRECATIONS,
resulting in warnings like:
gconf-helpers.c:1520:9: error: expected expression before '#pragma'
This is based on NM commit 80886c2866e6d61cc2f1e1b1bc26aa4ff84d0e4f, see it
for more info.
src/gconf-helpers/gconf-helpers.c | 42 ++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/src/gconf-helpers/gconf-helpers.c b/src/gconf-helpers/gconf-helpers.c
index 46b1fa0..53014be 100644
--- a/src/gconf-helpers/gconf-helpers.c
+++ b/src/gconf-helpers/gconf-helpers.c
@@ -1478,6 +1478,30 @@ out:
return success;
}
+static gboolean
+validate_gvalue_array (GValueArray *elements, guint n_expected, ...)
+{
+ va_list args;
+ GValue *tmp;
+ int i;
+ gboolean valid = FALSE;
+
+ if (n_expected != elements->n_values)
+ return FALSE;
+
+ va_start (args, n_expected);
+ for (i = 0; i < n_expected; i++) {
+ tmp = g_value_array_get_nth (elements, i);
+ if (G_VALUE_TYPE (tmp) != va_arg (args, GType))
+ goto done;
+ }
+ valid = TRUE;
+
+done:
+ va_end (args);
+ return valid;
+}
+
gboolean
nm_gconf_set_ip6addr_array_helper (GConfClient *client,
const char *path,
@@ -1517,14 +1541,13 @@ nm_gconf_set_ip6addr_array_helper (GConfClient *client,
goto out;
}
- if ( (G_VALUE_TYPE (g_value_array_get_nth (elements, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
- || (G_VALUE_TYPE (g_value_array_get_nth (elements, 1)) != G_TYPE_UINT)) {
+ if (!validate_gvalue_array (elements, 2, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT)) {
g_warning ("%s: invalid IPv6 address!", __func__);
goto out;
}
- if ( (elements->n_values == 3)
- && (G_VALUE_TYPE (g_value_array_get_nth (elements, 2)) != DBUS_TYPE_G_UCHAR_ARRAY)) {
+ if ( elements->n_values == 3
+ && !validate_gvalue_array (elements, 3, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT,
DBUS_TYPE_G_UCHAR_ARRAY)) {
g_warning ("%s: invalid IPv6 gateway!", __func__);
goto out;
}
@@ -1605,12 +1628,11 @@ nm_gconf_set_ip6route_array_helper (GConfClient *client,
guint prefix, metric;
char dest[INET6_ADDRSTRLEN], next_hop[INET6_ADDRSTRLEN];
- if ( (elements->n_values != 4)
- || (G_VALUE_TYPE (g_value_array_get_nth (elements, 0)) != DBUS_TYPE_G_UCHAR_ARRAY)
- || (G_VALUE_TYPE (g_value_array_get_nth (elements, 1)) != G_TYPE_UINT)
- || (G_VALUE_TYPE (g_value_array_get_nth (elements, 2)) != DBUS_TYPE_G_UCHAR_ARRAY)
- || (G_VALUE_TYPE (g_value_array_get_nth (elements, 3)) != G_TYPE_UINT))
- {
+ if (!validate_gvalue_array (elements, 4,
+ DBUS_TYPE_G_UCHAR_ARRAY,
+ G_TYPE_UINT,
+ DBUS_TYPE_G_UCHAR_ARRAY,
+ G_TYPE_UINT)) {
g_warning ("%s: invalid IPv6 route!", __func__);
goto out;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]