telepathy-idle: Fix some confusing variable-shadowing by just reusing the variables

Simon McVittie smcv at kemper.freedesktop.org
Wed May 30 05:08:46 PDT 2012


Module: telepathy-idle
Branch: master
Commit: 3e6a3e363f6486dc35fb2e1fbf4de04946e60594
URL:    http://cgit.freedesktop.org/telepathy/telepathy-idle/commit/?id=3e6a3e363f6486dc35fb2e1fbf4de04946e60594

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Thu May 10 14:16:54 2012 +0100

Fix some confusing variable-shadowing by just reusing the variables

This code is a bit of a mess, and it implements Telepathy 0.x
Properties by hand, without even using the (now deprecated!) mixin,
but I'm not going to fix that right now.

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Xavier Claessens <xavier.claessens at collabora.co.uk>

---

 src/idle-muc-channel.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/idle-muc-channel.c b/src/idle-muc-channel.c
index c27c704..028ca40 100644
--- a/src/idle-muc-channel.c
+++ b/src/idle-muc-channel.c
@@ -907,12 +907,13 @@ static void change_mode_state(IdleMUCChannel *obj, guint add, guint remove) {
 						1, val,
 						G_MAXUINT);
 
+				/* ownership of prop's contents is given to
+				 * the GPtrArray */
 				g_ptr_array_add(tp_props_to_change, g_value_get_boxed(&prop));
 
 				if (add & i) {
-					GValue prop = {0, };
-					GValue val_auto_is_fine = {0, };
-					GValue *val = &val_auto_is_fine;
+					/* this re-uses prop and val by
+					 * re-initializing them */
 
 					g_value_init(&prop, TP_STRUCT_TYPE_PROPERTY_VALUE);
 					g_value_take_boxed(&prop, dbus_g_type_specialized_construct(TP_STRUCT_TYPE_PROPERTY_VALUE));
@@ -934,6 +935,8 @@ static void change_mode_state(IdleMUCChannel *obj, guint add, guint remove) {
 											1, val,
 											G_MAXUINT);
 
+					/* ownership of prop's contents is
+					 * given to the GPtrArray */
 					g_ptr_array_add(tp_props_to_change, g_value_get_boxed(&prop));
 				}
 			}



More information about the telepathy-commits mailing list