all: use G_VALUE_INIT to initialize GValue variables

It makes the initializations more explicit.
G_VALUE_INIT is available since glib 2.30, and NM now require glib >= 2.32
This commit is contained in:
Jiří Klimeš 2013-03-22 10:49:19 +01:00
parent a78a1847c6
commit 82fb1978a4
21 changed files with 57 additions and 57 deletions

View file

@ -175,7 +175,7 @@ next_script (gpointer user_data)
results = g_ptr_array_sized_new (request->scripts->len);
for (i = 0; i < request->scripts->len; i++) {
ScriptInfo *script = g_ptr_array_index (request->scripts, i);
GValue elt = {0, };
GValue elt = G_VALUE_INIT;
item = g_value_array_new (3);

View file

@ -1257,7 +1257,7 @@ dbus_get_vpn_state (const char *path)
DBusGConnection *connection;
DBusGProxy *proxy;
GError *error = NULL;
GValue value = {0,};
GValue value = G_VALUE_INIT;
NMVPNConnectionState state = NM_VPN_CONNECTION_STATE_UNKNOWN;
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);

View file

@ -98,8 +98,8 @@ static void
get_active_connection_details (DBusGConnection *bus, const char *obj_path)
{
DBusGProxy *props_proxy;
GValue path_value = { 0 };
GValue serv_value = { 0 };
GValue path_value = G_VALUE_INIT;
GValue serv_value = G_VALUE_INIT;
GError *error = NULL;
const char *path = NULL, *service = NULL;
@ -179,7 +179,7 @@ static void
get_active_connections (DBusGConnection *bus, DBusGProxy *proxy)
{
GError *error = NULL;
GValue value = { 0 };
GValue value = G_VALUE_INIT;
GPtrArray *paths = NULL;
int i;

View file

@ -111,7 +111,7 @@ _nm_active_connection_type_for_path (DBusGConnection *connection,
{
DBusGProxy *proxy;
GError *error = NULL;
GValue value = {0,};
GValue value = G_VALUE_INIT;
GType type;
proxy = dbus_g_proxy_new_for_name (connection,

View file

@ -768,7 +768,7 @@ nm_client_wireless_get_enabled (NMClient *client)
void
nm_client_wireless_set_enabled (NMClient *client, gboolean enabled)
{
GValue value = {0,};
GValue value = G_VALUE_INIT;
g_return_if_fail (NM_IS_CLIENT (client));
@ -825,7 +825,7 @@ nm_client_wwan_get_enabled (NMClient *client)
void
nm_client_wwan_set_enabled (NMClient *client, gboolean enabled)
{
GValue value = {0,};
GValue value = G_VALUE_INIT;
g_return_if_fail (NM_IS_CLIENT (client));
@ -882,7 +882,7 @@ nm_client_wimax_get_enabled (NMClient *client)
void
nm_client_wimax_set_enabled (NMClient *client, gboolean enabled)
{
GValue value = {0,};
GValue value = G_VALUE_INIT;
g_return_if_fail (NM_IS_CLIENT (client));

View file

@ -845,7 +845,7 @@ _nm_device_type_for_path (DBusGConnection *connection,
{
DBusGProxy *proxy;
GError *err = NULL;
GValue value = {0,};
GValue value = G_VALUE_INIT;
NMDeviceType nm_dtype;
proxy = dbus_g_proxy_new_for_name (connection,
@ -1146,7 +1146,7 @@ nm_device_get_autoconnect (NMDevice *device)
void
nm_device_set_autoconnect (NMDevice *device, gboolean autoconnect)
{
GValue value = {0,};
GValue value = G_VALUE_INIT;
g_return_if_fail (NM_IS_DEVICE (device));

View file

@ -1090,7 +1090,7 @@ _nm_object_reload_property (NMObject *object,
const char *interface,
const char *prop_name)
{
GValue value = { 0, };
GValue value = G_VALUE_INIT;
GError *err = NULL;
g_return_if_fail (NM_IS_OBJECT (object));
@ -1281,7 +1281,7 @@ _nm_object_reload_pseudo_property (NMObject *object,
PseudoPropertyInfo *ppi;
GPtrArray *temp;
GError *error = NULL;
GValue value = { 0, };
GValue value = G_VALUE_INIT;
g_return_if_fail (NM_IS_OBJECT (object));
g_return_if_fail (name != NULL);
@ -1365,7 +1365,7 @@ reload_got_pseudo_property (DBusGProxy *proxy, DBusGProxyCall *call,
NMObject *object = ppi->self;
NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
GPtrArray *temp;
GValue value = { 0, };
GValue value = G_VALUE_INIT;
GError *error = NULL;
if (dbus_g_proxy_end_call (proxy, call, &error,

View file

@ -649,8 +649,8 @@ _nm_param_spec_specialized (const char *name,
static void
compare_ints (void)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
g_value_init (&value1, G_TYPE_INT);
g_value_init (&value2, G_TYPE_INT);
@ -669,8 +669,8 @@ compare_ints (void)
static void
compare_strings (void)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
const char *str1 = "hello";
const char *str2 = "world";
@ -688,8 +688,8 @@ compare_strings (void)
static void
compare_strv (void)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
char *strv1[] = { "foo", "bar", "baz", NULL };
char *strv2[] = { "foo", "bar", "bar", NULL };
char *strv3[] = { "foo", "bar", NULL };
@ -717,8 +717,8 @@ compare_garrays (void)
{
GArray *array1;
GArray *array2;
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
int i;
g_value_init (&value1, DBUS_TYPE_G_UINT_ARRAY);
@ -752,8 +752,8 @@ compare_ptrarrays (void)
{
GPtrArray *array1;
GPtrArray *array2;
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
g_value_init (&value1, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
array1 = g_ptr_array_new ();
@ -785,8 +785,8 @@ compare_str_hash (void)
{
GHashTable *hash1;
GHashTable *hash2;
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
@ -842,8 +842,8 @@ compare_gvalue_hash (void)
{
GHashTable *hash1;
GHashTable *hash2;
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
@ -879,9 +879,9 @@ compare_ip6_addresses (void)
GByteArray *ba1;
GByteArray *ba2;
GByteArray *ba3;
GValue element = { 0 };
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue element = G_VALUE_INIT;
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
struct in6_addr addr1;
struct in6_addr addr2;
struct in6_addr addr3;

View file

@ -316,8 +316,8 @@ compare_property (NMSetting *setting,
const GParamSpec *prop_spec,
NMSettingCompareFlags flags)
{
GValue value1 = { 0 };
GValue value2 = { 0 };
GValue value1 = G_VALUE_INIT;
GValue value2 = G_VALUE_INIT;
gboolean different;
/* Handle compare flags */
@ -510,7 +510,7 @@ nm_setting_diff (NMSetting *a,
for (i = 0; i < n_property_specs; i++) {
GParamSpec *prop_spec = property_specs[i];
GValue a_value = { 0 }, b_value = { 0 };
GValue a_value = G_VALUE_INIT, b_value = G_VALUE_INIT;
NMSettingDiffResult r = NM_SETTING_DIFF_RESULT_UNKNOWN, tmp;
gboolean different = TRUE;
@ -580,7 +580,7 @@ nm_setting_enumerate_values (NMSetting *setting,
property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (setting), &n_property_specs);
for (i = 0; i < n_property_specs; i++) {
GParamSpec *prop_spec = property_specs[i];
GValue value = { 0 };
GValue value = G_VALUE_INIT;
g_value_init (&value, G_PARAM_SPEC_VALUE_TYPE (prop_spec));
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value);
@ -612,7 +612,7 @@ nm_setting_clear_secrets (NMSetting *setting)
for (i = 0; i < n_property_specs; i++) {
GParamSpec *prop_spec = property_specs[i];
GValue value = { 0 };
GValue value = G_VALUE_INIT;
if (prop_spec->flags & NM_SETTING_PARAM_SECRET) {
g_value_init (&value, prop_spec->value_type);
@ -631,7 +631,7 @@ clear_secrets_with_flags (NMSetting *setting,
NMSettingClearSecretsWithFlagsFn func,
gpointer user_data)
{
GValue value = { 0 };
GValue value = G_VALUE_INIT;
NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE;
/* Clear the secret if the user function says to do so */
@ -710,7 +710,7 @@ static gboolean
update_one_secret (NMSetting *setting, const char *key, GValue *value, GError **error)
{
GParamSpec *prop_spec;
GValue transformed_value = { 0 };
GValue transformed_value = G_VALUE_INIT;
gboolean success = FALSE;
prop_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), key);
@ -929,7 +929,7 @@ nm_setting_to_string (NMSetting *setting)
for (i = 0; i < n_property_specs; i++) {
GParamSpec *prop_spec = property_specs[i];
GValue value = { 0 };
GValue value = G_VALUE_INIT;
char *value_str;
gboolean is_serializable;
gboolean is_default;

View file

@ -1091,7 +1091,7 @@ _nm_utils_convert_old_ip6_addr_array (const GValue *src_value, GValue *dst_value
for (i = 0; src_outer_array && (i < src_outer_array->len); i++) {
GValueArray *src_addr_array;
GValueArray *dst_addr_array;
GValue element = {0, };
GValue element = G_VALUE_INIT;
GValue *src_addr, *src_prefix;
GByteArray *ba;
@ -1867,7 +1867,7 @@ nm_utils_ip6_addresses_to_gvalue (GSList *list, GValue *value)
for (iter = list; iter; iter = iter->next) {
NMIP6Address *addr = (NMIP6Address *) iter->data;
GValueArray *array;
GValue element = {0, };
GValue element = G_VALUE_INIT;
GByteArray *ba;
array = g_value_array_new (3);
@ -1991,7 +1991,7 @@ nm_utils_ip6_routes_to_gvalue (GSList *list, GValue *value)
GValueArray *array;
const struct in6_addr *addr;
GByteArray *ba;
GValue element = {0, };
GValue element = G_VALUE_INIT;
array = g_value_array_new (4);

View file

@ -145,7 +145,7 @@ test_setting_vpn_update_secrets (void)
NMConnection *connection;
NMSettingVPN *s_vpn;
GHashTable *settings, *vpn, *secrets;
GValue val = { 0 };
GValue val = G_VALUE_INIT;
gboolean success;
GError *error = NULL;
const char *tmp;
@ -280,7 +280,7 @@ test_setting_ip6_config_old_address_array (void)
NMSettingIP6Config *s_ip6;
GPtrArray *addresses, *read_addresses;
GValueArray *array, *read_array;
GValue element = {0, }, written_value = {0, }, read_value = {0, };
GValue element = G_VALUE_INIT, written_value = G_VALUE_INIT, read_value = G_VALUE_INIT;
GByteArray *ba;
const guint8 addr[16] = { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
0x11, 0x22, 0x33, 0x44, 0x66, 0x77, 0x88, 0x99 };

View file

@ -57,8 +57,8 @@ test_defaults (GType type, const char *name)
for (i = 0; i < n_property_specs; i++) {
GParamSpec *prop_spec = property_specs[i];
GValue value = { 0, };
GValue defvalue = { 0, };
GValue value = G_VALUE_INIT;
GValue defvalue = G_VALUE_INIT;
char *actual, *expected;
gboolean ok = FALSE;

View file

@ -92,7 +92,7 @@ get_mm_enabled_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_d
{
NMModem *self = NM_MODEM (user_data);
GError *error = NULL;
GValue value = { 0, };
GValue value = G_VALUE_INIT;
if (!dbus_g_proxy_end_call (proxy, call_id, &error,
G_TYPE_VALUE, &value,

View file

@ -222,7 +222,7 @@ set_sysfs_uint (const char *iface,
{
char *path, *s;
GParamSpec *pspec;
GValue val = { 0 };
GValue val = G_VALUE_INIT;
guint32 uval = 0;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (obj), obj_prop);

View file

@ -1636,8 +1636,8 @@ scanning_allowed_accumulator (GSignalInvocationHint *ihint,
static gboolean
check_scanning_allowed (NMDeviceWifi *self)
{
GValue instance = { 0, };
GValue retval = { 0, };
GValue instance = G_VALUE_INIT;
GValue retval = G_VALUE_INIT;
g_value_init (&instance, G_TYPE_OBJECT);
g_value_take_object (&instance, self);

View file

@ -1357,8 +1357,8 @@ gboolean
nm_device_autoconnect_allowed (NMDevice *self)
{
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
GValue instance = { 0, };
GValue retval = { 0, };
GValue instance = G_VALUE_INIT;
GValue retval = G_VALUE_INIT;
g_value_init (&instance, G_TYPE_OBJECT);
g_value_take_object (&instance, self);

View file

@ -75,7 +75,7 @@ static void
add_to_string (gpointer key, gpointer value, gpointer user_data)
{
char *buf = (char *) user_data;
GValue str_val = { 0, };
GValue str_val = G_VALUE_INIT;
g_value_init (&str_val, G_TYPE_STRING);
if (!g_value_transform ((GValue *) value, &str_val)) {

View file

@ -1291,7 +1291,7 @@ static guint32
get_setting_default (NMSetting *setting, const char *prop)
{
GParamSpec *pspec;
GValue val = { 0 };
GValue val = G_VALUE_INIT;
guint32 ret = 0;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (setting), prop);

View file

@ -132,7 +132,7 @@ build_ip6_address_or_route (const char *address_str, guint32 plen, const char *g
struct in6_addr addr;
GByteArray *address;
GByteArray *gateway;
GValue value = { 0, };
GValue value = G_VALUE_INIT;
int err;
g_return_val_if_fail (address_str, NULL);

View file

@ -1276,7 +1276,7 @@ nm_supplicant_interface_set_config (NMSupplicantInterface * self,
NMSupplicantInterfacePrivate *priv;
NMSupplicantInfo *info;
DBusGProxyCall *call;
GValue value = { 0, };
GValue value = G_VALUE_INIT;
g_return_val_if_fail (NM_IS_SUPPLICANT_INTERFACE (self), FALSE);

View file

@ -138,7 +138,7 @@ write_one_setting (FILE *f, gboolean book, SettingNewFunc func)
const char *key_name, *value_type, *value_desc;
char *default_value;
TypeNameElement *name_iter;
GValue value = { 0, };
GValue value = G_VALUE_INIT;
char *flags_str = NULL;
value_type = g_type_name (G_PARAM_SPEC_VALUE_TYPE (*iter));