[gnome-bluetooth] lib: Clean up priv assignments in killswitch



commit 88c81dcc4229f4c698683900e27c806337de0648
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jul 23 17:30:46 2012 +0100

    lib: Clean up priv assignments in killswitch

 lib/bluetooth-killswitch.c |   32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/lib/bluetooth-killswitch.c b/lib/bluetooth-killswitch.c
index 1229271..ae4761c 100644
--- a/lib/bluetooth-killswitch.c
+++ b/lib/bluetooth-killswitch.c
@@ -119,9 +119,12 @@ static void
 update_killswitch (BluetoothKillswitch *killswitch,
 		   guint index, guint soft, guint hard)
 {
-	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
+	BluetoothKillswitchPrivate *priv;
+	gboolean changed;
 	GList *l;
-	gboolean changed = FALSE;
+
+	priv = killswitch->priv;
+	changed = FALSE;
 
 	for (l = priv->killswitches; l != NULL; l = l->next) {
 		BluetoothIndKillswitch *ind = l->data;
@@ -149,12 +152,14 @@ void
 bluetooth_killswitch_set_state (BluetoothKillswitch *killswitch,
 				KillswitchState state)
 {
-	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
+	BluetoothKillswitchPrivate *priv;
 	struct rfkill_event event;
 	ssize_t len;
 
 	g_return_if_fail (state != KILLSWITCH_STATE_HARD_BLOCKED);
 
+	priv = killswitch->priv;
+
 	memset (&event, 0, sizeof(event));
 	event.op = RFKILL_OP_CHANGE_ALL;
 	event.type = RFKILL_TYPE_BLUETOOTH;
@@ -180,7 +185,7 @@ bluetooth_killswitch_get_state (BluetoothKillswitch *killswitch)
 
 	g_return_val_if_fail (BLUETOOTH_IS_KILLSWITCH (killswitch), state);
 
-	priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
+	priv = killswitch->priv;
 
 	if (priv->killswitches == NULL)
 		return KILLSWITCH_STATE_NO_ADAPTER;
@@ -212,7 +217,7 @@ bluetooth_killswitch_get_state (BluetoothKillswitch *killswitch)
 gboolean
 bluetooth_killswitch_has_killswitches (BluetoothKillswitch *killswitch)
 {
-	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
+	BluetoothKillswitchPrivate *priv = killswitch->priv;
 
 	g_return_val_if_fail (BLUETOOTH_IS_KILLSWITCH (killswitch), FALSE);
 
@@ -223,9 +228,11 @@ static void
 remove_killswitch (BluetoothKillswitch *killswitch,
 		   guint index)
 {
-	BluetoothKillswitchPrivate *priv = killswitch->priv;
+	BluetoothKillswitchPrivate *priv;
 	GList *l;
 
+	priv = killswitch->priv;
+
 	for (l = priv->killswitches; l != NULL; l = l->next) {
 		BluetoothIndKillswitch *ind = l->data;
 		if (ind->index == index) {
@@ -246,9 +253,11 @@ add_killswitch (BluetoothKillswitch *killswitch,
 		KillswitchState state)
 
 {
-	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
+	BluetoothKillswitchPrivate *priv;
 	BluetoothIndKillswitch *ind;
 
+	priv = killswitch->priv;
+
 	g_debug ("adding killswitch idx %d state %s", index, state_to_string (state));
 	ind = g_new0 (BluetoothIndKillswitch, 1);
 	ind->index = index;
@@ -363,10 +372,11 @@ carry_on:
 static void
 bluetooth_killswitch_init (BluetoothKillswitch *killswitch)
 {
-	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
+	BluetoothKillswitchPrivate *priv;
 	struct rfkill_event event;
 	int fd;
 
+	priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (killswitch);
 	killswitch->priv = priv;
 
 	fd = open("/dev/rfkill", O_RDWR);
@@ -424,7 +434,11 @@ bluetooth_killswitch_init (BluetoothKillswitch *killswitch)
 static void
 bluetooth_killswitch_finalize (GObject *object)
 {
-	BluetoothKillswitchPrivate *priv = BLUETOOTH_KILLSWITCH_GET_PRIVATE (object);
+	BluetoothKillswitch *killswitch;
+	BluetoothKillswitchPrivate *priv;
+
+	killswitch = BLUETOOTH_KILLSWITCH (object);
+	priv = killswitch->priv;
 
 	/* cleanup monitoring */
 	if (priv->watch_id > 0) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]