Commit d8437ffa authored by Dan Williams's avatar Dan Williams

core: fix deprecated usage of g_value_[get|set]_char() (bgo #662694)

parent c2d2f403
......@@ -16,7 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2008 Red Hat, Inc.
* (C) Copyright 2008 - 2011 Red Hat, Inc.
*/
#ifndef NM_GLIB_COMPAT_H
......@@ -24,14 +24,9 @@
#include <glib.h>
#if !GLIB_CHECK_VERSION(2,14,0)
#define g_timeout_add_seconds(i, f, d) \
g_timeout_add (i * G_USEC_PER_SEC, f, d)
#define g_timeout_add_seconds_full(p, i, f, d, n) \
g_timeout_add_full (p, i * G_USEC_PER_SEC, f, d, n)
#endif /* !GLIB_CHECK_VERSION(2,14,0) */
#if !GLIB_CHECK_VERSION(2,31,0)
#define g_value_set_schar g_value_set_char
#define g_value_get_schar g_value_get_char
#endif
#endif /* NM_GLIB_COMPAT_H */
......@@ -28,6 +28,7 @@
#include "nm-object-cache.h"
#include "nm-object-private.h"
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#define DEBUG 0
......@@ -438,11 +439,11 @@ _nm_object_handle_properties_changed (NMObject *object,
}
}
#define HANDLE_TYPE(ucase, lcase) \
#define HANDLE_TYPE(ucase, lcase, getter) \
} else if (pspec->value_type == G_TYPE_##ucase) { \
if (G_VALUE_HOLDS_##ucase (value)) { \
g##lcase *param = (g##lcase *) field; \
*param = g_value_get_##lcase (value); \
*param = g_value_get_##getter (value); \
} else { \
success = FALSE; \
goto done; \
......@@ -474,16 +475,16 @@ _nm_object_demarshal_generic (NMObject *object,
success = FALSE;
goto done;
}
HANDLE_TYPE(BOOLEAN, boolean)
HANDLE_TYPE(CHAR, char)
HANDLE_TYPE(UCHAR, uchar)
HANDLE_TYPE(DOUBLE, double)
HANDLE_TYPE(INT, int)
HANDLE_TYPE(UINT, uint)
HANDLE_TYPE(INT64, int)
HANDLE_TYPE(UINT64, uint)
HANDLE_TYPE(LONG, long)
HANDLE_TYPE(ULONG, ulong)
HANDLE_TYPE(BOOLEAN, boolean, boolean)
HANDLE_TYPE(CHAR, char, schar)
HANDLE_TYPE(UCHAR, uchar, uchar)
HANDLE_TYPE(DOUBLE, double, double)
HANDLE_TYPE(INT, int, int)
HANDLE_TYPE(UINT, uint, uint)
HANDLE_TYPE(INT64, int, int)
HANDLE_TYPE(UINT64, uint, uint)
HANDLE_TYPE(LONG, long, long)
HANDLE_TYPE(ULONG, ulong, ulong)
} else {
g_warning ("%s: %s/%s unhandled type %s.",
__func__, G_OBJECT_TYPE_NAME (object), pspec->name,
......
......@@ -19,11 +19,12 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
#include "nm-param-spec-specialized.h"
#include "nm-glib-compat.h"
struct _NMParamSpecSpecialized {
GParamSpec parent;
......@@ -92,13 +93,8 @@ _gvalues_compare_fixed (const GValue *value1, const GValue *value2)
switch (G_VALUE_TYPE (value1)) {
case G_TYPE_CHAR: {
#if GLIB_CHECK_VERSION(2,31,0)
gchar val1 = g_value_get_schar (value1);
gchar val2 = g_value_get_schar (value2);
#else
gchar val1 = g_value_get_char (value1);
gchar val2 = g_value_get_char (value2);
#endif
if (val1 != val2)
ret = val1 < val2 ? -1 : val1 > val2;
break;
......
......@@ -26,6 +26,7 @@
#include <string.h>
#include "nm-setting-serial.h"
#include "nm-glib-compat.h"
/**
* SECTION:nm-setting-serial
......@@ -214,7 +215,7 @@ set_property (GObject *object, guint prop_id,
priv->bits = g_value_get_uint (value);
break;
case PROP_PARITY:
priv->parity = g_value_get_char (value);
priv->parity = g_value_get_schar (value);
break;
case PROP_STOPBITS:
priv->stopbits = g_value_get_uint (value);
......@@ -242,7 +243,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, nm_setting_serial_get_bits (setting));
break;
case PROP_PARITY:
g_value_set_char (value, nm_setting_serial_get_parity (setting));
g_value_set_schar (value, nm_setting_serial_get_parity (setting));
break;
case PROP_STOPBITS:
g_value_set_uint (value, nm_setting_serial_get_stopbits (setting));
......
......@@ -33,6 +33,7 @@
#include "wpa.h"
#include "nm-properties-changed-signal.h"
#include "nm-setting-wireless.h"
#include "nm-glib-compat.h"
#include "nm-access-point-glue.h"
......@@ -141,7 +142,7 @@ set_property (GObject *object, guint prop_id,
nm_ap_set_max_bitrate (ap, g_value_get_uint (value));
break;
case PROP_STRENGTH:
nm_ap_set_strength (ap, g_value_get_char (value));
nm_ap_set_strength (ap, g_value_get_schar (value));
break;
case PROP_HW_ADDRESS:
break;
......@@ -191,7 +192,7 @@ get_property (GObject *object, guint prop_id,
g_value_set_uint (value, priv->max_bitrate);
break;
case PROP_STRENGTH:
g_value_set_char (value, priv->strength);
g_value_set_schar (value, priv->strength);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
......
......@@ -44,6 +44,7 @@
#include <ctype.h>
#include "nm-dbus-glib-types.h"
#include "nm-glib-compat.h"
#include "writer.h"
#include "common.h"
......@@ -890,7 +891,7 @@ write_setting_value (NMSetting *setting,
} else if (type == G_TYPE_BOOLEAN) {
g_key_file_set_boolean (info->keyfile, setting_name, key, g_value_get_boolean (value));
} else if (type == G_TYPE_CHAR) {
g_key_file_set_integer (info->keyfile, setting_name, key, (int) g_value_get_char (value));
g_key_file_set_integer (info->keyfile, setting_name, key, (int) g_value_get_schar (value));
} else if (type == DBUS_TYPE_G_UCHAR_ARRAY) {
GByteArray *array;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment