From 0a0ef1fab449ffb493fb8a309ce49f8f605188b7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 7 Sep 2012 11:11:23 +0100 Subject: [PATCH 6/8] Use G_VALUE_INIT instead of { 0 } We already depend on GLib 2.30, which is new enough. Signed-off-by: Simon McVittie --- src/channel-utils.c | 2 +- src/mcd-account-manager-sso.c | 16 ++++++++-------- src/mcd-account-manager.c | 4 ++-- src/mcd-account.c | 38 ++++++++++++++++++------------------- src/mcd-channel.c | 6 +++--- src/mcd-dbusprop.c | 2 +- src/mcd-dispatcher.c | 6 +++--- src/mcd-storage.c | 2 +- tests/account-store-libaccounts.c | 14 +++++++------- tests/value-is-same.c | 16 ++++++++++++---- 10 files changed, 57 insertions(+), 49 deletions(-) diff --git a/src/channel-utils.c b/src/channel-utils.c index 74a62a8..492b54b 100644 --- a/src/channel-utils.c +++ b/src/channel-utils.c @@ -82,7 +82,7 @@ static void _channel_details_array_append (GPtrArray *channel_array, TpChannel *channel) { GType type = TP_STRUCT_TYPE_CHANNEL_DETAILS; - GValue channel_val = { 0, }; + GValue channel_val = G_VALUE_INIT; GHashTable *properties; const gchar *object_path; diff --git a/src/mcd-account-manager-sso.c b/src/mcd-account-manager-sso.c index 3be991e..8e22ded 100644 --- a/src/mcd-account-manager-sso.c +++ b/src/mcd-account-manager-sso.c @@ -348,7 +348,7 @@ _maybe_set_account_param_from_service ( { Setting *setting = setting_data (AG_ACCOUNT_KEY, SETTING_AG); AgSettingSource source = AG_SETTING_SOURCE_NONE; - GValue ag_value = { 0 }; + GValue ag_value = G_VALUE_INIT; g_return_if_fail (setting != NULL); g_return_if_fail (ag_account != NULL); @@ -820,7 +820,7 @@ _ag_account_stored_cb ( gpointer user_data) { McdAccountManagerSso *self = MCD_ACCOUNT_MANAGER_SSO (user_data); - GValue uid = { 0 }; + GValue uid = G_VALUE_INIT; const gchar *name = NULL; AgSettingSource src = AG_SETTING_SOURCE_NONE; @@ -849,7 +849,7 @@ _ag_accountid_to_mc_key (McdAccountManagerSso *sso, AgAccount *account = ag_manager_get_account (sso->ag_manager, id); AgSettingSource src = AG_SETTING_SOURCE_NONE; AgService *service = NULL; - GValue value = { 0 }; + GValue value = G_VALUE_INIT; if (account == NULL) { @@ -896,8 +896,8 @@ _ag_accountid_to_mc_key (McdAccountManagerSso *sso, AgAccountSettingIter iter; const gchar *k; const GValue *v; - GValue cmanager = { 0 }; - GValue protocol = { 0 }; + GValue cmanager = G_VALUE_INIT; + GValue protocol = G_VALUE_INIT; const gchar *cman, *proto; McpAccountManager *am = sso->manager_interface; GHashTable *params = g_hash_table_new_full (g_str_hash, g_str_equal, @@ -1035,7 +1035,7 @@ save_setting ( if (setting->readable) { - GValue old = { 0 }; + GValue old = G_VALUE_INIT; AgSettingSource src = AG_SETTING_SOURCE_NONE; g_value_init (&old, G_TYPE_STRING); @@ -1068,7 +1068,7 @@ save_setting ( if (val != NULL) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, val); @@ -1186,7 +1186,7 @@ account_manager_sso_get_one ( } else { - GValue v = { 0 }; + GValue v = G_VALUE_INIT; AgSettingSource src = AG_SETTING_SOURCE_NONE; Setting *setting = setting_data (key, SETTING_MC); diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c index 9a12d1b..e7b2161 100644 --- a/src/mcd-account-manager.c +++ b/src/mcd-account-manager.c @@ -1237,8 +1237,8 @@ migrate_butterfly_haze_ready (McdManager *manager, { MigrateCtx *ctx = user_data; gchar *display_name; - GValue v = {0,}; - GValue password_v = {0,}; + GValue v = G_VALUE_INIT; + GValue password_v = G_VALUE_INIT; GHashTable *parameters, *properties; gchar *str; GPtrArray *supersedes; diff --git a/src/mcd-account.c b/src/mcd-account.c index a07e126..9a34323 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -855,7 +855,7 @@ mcd_account_request_presence_int (McdAccount *account, if (changed) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE); g_value_take_boxed (&value, @@ -1194,7 +1194,7 @@ _mcd_account_set_enabled (McdAccount *account, if (priv->enabled != enabled) { - GValue value = { 0, }; + GValue value = G_VALUE_INIT; const gchar *name = mcd_account_get_unique_name (account); if (!enabled && priv->connection != NULL) @@ -1485,7 +1485,7 @@ set_automatic_presence (TpSvcDBusProperties *self, if (priv->auto_presence_type != type) { - GValue presence = { 0 }; + GValue presence = G_VALUE_INIT; g_value_init (&presence, G_TYPE_INT); g_value_set_int (&presence, type); @@ -1898,7 +1898,7 @@ get_storage_identifier (TpSvcDBusProperties *self, McdAccount *account = MCD_ACCOUNT (self); McpAccountStorage *storage_plugin = get_storage_plugin (account); - GValue identifier = { 0 }; + GValue identifier = G_VALUE_INIT; g_value_init (value, G_TYPE_VALUE); @@ -2308,7 +2308,7 @@ mcd_account_property_changed (McdAccount *account, const gchar *name) if (prop->getprop != NULL) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; prop->getprop (self, name, &value); @@ -2487,7 +2487,7 @@ check_one_parameter_update (McdAccount *account, if (mcd_account_get_connection_status (account) == TP_CONNECTION_STATUS_CONNECTED) { - GValue current_value = { 0, }; + GValue current_value = G_VALUE_INIT; /* Check if the parameter's current value (or its default, if it has * one and it's not set to anything) matches the new value. @@ -2533,7 +2533,7 @@ check_one_parameter_unset (McdAccount *account, mcd_account_get_connection_status (account) == TP_CONNECTION_STATUS_CONNECTED) { - GValue current_value = { 0, }; + GValue current_value = G_VALUE_INIT; if (mcd_account_get_parameter (account, param->name, ¤t_value, NULL)) @@ -2541,7 +2541,7 @@ check_one_parameter_unset (McdAccount *account, /* There's an existing value; let's see if it's the same as the * default, if any. */ - GValue default_value = { 0, }; + GValue default_value = G_VALUE_INIT; if (tp_connection_manager_param_get_default (param, &default_value)) { @@ -2679,7 +2679,7 @@ account_update_parameters_cb (McdAccount *account, GPtrArray *not_yet, DBusGMethodInvocation *context = (DBusGMethodInvocation *) user_data; const gchar *account_name = mcd_account_get_unique_name (account); GHashTable *params; - GValue value = { 0 }; + GValue value = G_VALUE_INIT; if (error != NULL) { @@ -3362,7 +3362,7 @@ _mcd_account_dup_parameters (McdAccount *account) for (param = protocol->params; param->name != NULL; param++) { - GValue v = { 0, }; + GValue v = G_VALUE_INIT; if (mcd_account_get_parameter (account, param->name, &v, NULL)) { @@ -3403,7 +3403,7 @@ mcd_account_update_self_presence (McdAccount *account, { McdAccountPrivate *priv = account->priv; gboolean changed = FALSE; - GValue value = { 0 }; + GValue value = G_VALUE_INIT; if (priv->curr_presence_type != presence) { @@ -3581,7 +3581,7 @@ void _mcd_account_set_normalized_name (McdAccount *account, const gchar *name) { McdAccountPrivate *priv = account->priv; - GValue value = { 0, }; + GValue value = G_VALUE_INIT; const gchar *account_name = mcd_account_get_unique_name (account); DEBUG ("called (%s)", name); @@ -3756,7 +3756,7 @@ mcd_account_connection_self_nickname_changed_cb (McdAccount *account, const gchar *alias, McdConnection *connection) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; g_value_init (&value, G_TYPE_STRING); g_value_set_static_string (&value, alias); @@ -3852,7 +3852,7 @@ clear_register (McdAccount *self) if (tp_asv_get_boolean (params, "register", NULL)) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; const gchar *account_name = mcd_account_get_unique_name (self); _mcd_account_set_parameter (self, "register", NULL); @@ -3961,7 +3961,7 @@ _mcd_account_set_connection_status (McdAccount *account, if (changed) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; _mcd_account_tp_connection_changed (account, priv->tp_connection); @@ -4009,7 +4009,7 @@ void _mcd_account_tp_connection_changed (McdAccount *account, TpConnection *tp_conn) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); @@ -4060,7 +4060,7 @@ check_validity_check_parameters_cb (McdAccount *account, if (was_valid != now_valid) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; DEBUG ("Account validity changed (old: %d, new: %d)", was_valid, now_valid); g_signal_emit (account, _mcd_account_signals[VALIDITY_CHANGED], 0, @@ -4346,7 +4346,7 @@ _mcd_account_set_has_been_online (McdAccount *account) { if (!account->priv->has_been_online) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; const gchar *account_name = mcd_account_get_unique_name (account); g_value_init (&value, G_TYPE_BOOLEAN); @@ -4469,7 +4469,7 @@ void _mcd_account_set_changing_presence (McdAccount *self, gboolean value) { McdAccountPrivate *priv = self->priv; - GValue changing_presence = { 0 }; + GValue changing_presence = G_VALUE_INIT; priv->changing_presence = value; diff --git a/src/mcd-channel.c b/src/mcd-channel.c index e32281e..3d6b066 100644 --- a/src/mcd-channel.c +++ b/src/mcd-channel.c @@ -657,9 +657,9 @@ mcd_channel_new_from_path (TpConnection *connection, const gchar *object_path, TpHandleType handle_type) { GHashTable *props; - GValue v_type = { 0 }; - GValue v_handle = { 0 }; - GValue v_handle_type = { 0 }; + GValue v_type = G_VALUE_INIT; + GValue v_handle = G_VALUE_INIT; + GValue v_handle_type = G_VALUE_INIT; McdChannel *channel; props = g_hash_table_new (g_str_hash, g_str_equal); diff --git a/src/mcd-dbusprop.c b/src/mcd-dbusprop.c index 01307f6..f15bd85 100644 --- a/src/mcd-dbusprop.c +++ b/src/mcd-dbusprop.c @@ -236,7 +236,7 @@ dbusprop_get (TpSvcDBusProperties *self, const gchar *property_name, DBusGMethodInvocation *context) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; GError *error = NULL; DEBUG ("%s, %s", interface_name, property_name); diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c index c7f3c7a..48ebc83 100644 --- a/src/mcd-dispatcher.c +++ b/src/mcd-dispatcher.c @@ -1719,9 +1719,9 @@ messages_send_message_start (DBusGMethodInvocation *dbus_context, McdRequest *request = NULL; GError *error = NULL; GHashTable *props = NULL; - GValue c_type = { 0 }; - GValue h_type = { 0 }; - GValue target = { 0 }; + GValue c_type = G_VALUE_INIT; + GValue h_type = G_VALUE_INIT; + GValue target = G_VALUE_INIT; McdDispatcher *self = message->dispatcher; DEBUG ("messages_send_message_acl_success [attempt #%u]", message->tries); diff --git a/src/mcd-storage.c b/src/mcd-storage.c index 814474c..0ab1ff2 100644 --- a/src/mcd-storage.c +++ b/src/mcd-storage.c @@ -1154,7 +1154,7 @@ mcd_storage_set_strv (McdStorage *storage, const gchar * const *strv, gboolean secret) { - GValue v = { 0, }; + GValue v = G_VALUE_INIT; static const gchar * const *empty = { NULL }; gboolean ret; diff --git a/tests/account-store-libaccounts.c b/tests/account-store-libaccounts.c index 249b847..e275696 100644 --- a/tests/account-store-libaccounts.c +++ b/tests/account-store-libaccounts.c @@ -250,7 +250,7 @@ get_ag_account (const gchar *mc_account) if (account != NULL) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; AgSettingSource source = AG_SETTING_SOURCE_NONE; g_value_init (&value, G_TYPE_STRING); @@ -370,7 +370,7 @@ save_setting (AgAccount *account, if (val != NULL) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; g_value_init (&value, G_TYPE_STRING); g_value_set_string (&value, val); @@ -416,7 +416,7 @@ libaccounts_get (const gchar *mc_account, const gchar *key) } else { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; AgSettingSource source = AG_SETTING_SOURCE_NONE; g_value_init (&value, G_TYPE_STRING); @@ -567,7 +567,7 @@ libaccounts_list (void) for (id = ag_ids; id && i < len; id = g_list_next (id)) { - GValue value = { 0 }; + GValue value = G_VALUE_INIT; AgAccountId uid = GPOINTER_TO_UINT (id->data); AgAccount *ag_account = ag_manager_get_account (ag_manager, uid); AgSettingSource source = AG_SETTING_SOURCE_NONE; @@ -589,9 +589,9 @@ libaccounts_list (void) } else { - GValue cmanager = { 0 }; - GValue protocol = { 0 }; - GValue account = { 0 }; + GValue cmanager = G_VALUE_INIT; + GValue protocol = G_VALUE_INIT; + GValue account = G_VALUE_INIT; const gchar *acct = NULL; const gchar *cman = NULL; const gchar *proto = NULL; diff --git a/tests/value-is-same.c b/tests/value-is-same.c index f0b5c36..1f7854b 100644 --- a/tests/value-is-same.c +++ b/tests/value-is-same.c @@ -57,7 +57,9 @@ assert_and_reset (GValue *value, GValue *same, GValue *different) static void test_numeric (void) { - GValue value = { 0 }, same = { 0 }, different = { 0 }; + GValue value = G_VALUE_INIT; + GValue same = G_VALUE_INIT; + GValue different = G_VALUE_INIT; g_value_set_int (g_value_init (&value, G_TYPE_INT), -42); g_value_set_int (g_value_init (&same, G_TYPE_INT), -42); @@ -103,7 +105,9 @@ test_numeric (void) static void test_string (void) { - GValue value = { 0 }, same = { 0 }, different = { 0 }; + GValue value = G_VALUE_INIT; + GValue same = G_VALUE_INIT; + GValue different = G_VALUE_INIT; g_value_init (&value, G_TYPE_STRING); g_value_init (&same, G_TYPE_STRING); @@ -132,7 +136,9 @@ test_string (void) static void test_object_path (void) { - GValue value = { 0 }, same = { 0 }, different = { 0 }; + GValue value = G_VALUE_INIT; + GValue same = G_VALUE_INIT; + GValue different = G_VALUE_INIT; g_value_init (&value, DBUS_TYPE_G_OBJECT_PATH); g_value_init (&same, DBUS_TYPE_G_OBJECT_PATH); @@ -154,7 +160,9 @@ test_strv (void) const gchar * const empty[] = { NULL }; const gchar * const small[] = { "foo", "bar", NULL }; const gchar * const large[] = { "foo", "bar", "baz", NULL }; - GValue value = { 0 }, same = { 0 }, different = { 0 }; + GValue value = G_VALUE_INIT; + GValue same = G_VALUE_INIT; + GValue different = G_VALUE_INIT; g_value_init (&value, G_TYPE_STRV); g_value_init (&same, G_TYPE_STRV); -- 1.7.10.4