[asterisk-commits] rmudgett: branch group/bridge_construction r385807 - /team/group/bridge_const...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 15 13:32:13 CDT 2013


Author: rmudgett
Date: Mon Apr 15 13:32:09 2013
New Revision: 385807

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385807
Log:
Remove some unnecessary NULL pointer checks.

Modified:
    team/group/bridge_construction/main/bridging.c

Modified: team/group/bridge_construction/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/group/bridge_construction/main/bridging.c?view=diff&rev=385807&r1=385806&r2=385807
==============================================================================
--- team/group/bridge_construction/main/bridging.c (original)
+++ team/group/bridge_construction/main/bridging.c Mon Apr 15 13:32:09 2013
@@ -463,8 +463,7 @@
 	case AST_BRIDGE_CHANNEL_STATE_END:
 		/* Do we need to dissolve the bridge because this channel hung up? */
 		if (ast_test_flag(&bridge->feature_flags, AST_BRIDGE_FLAG_DISSOLVE_HANGUP)
-			|| (bridge_channel->features
-				&& bridge_channel->features->usable
+			|| (bridge_channel->features->usable
 				&& ast_test_flag(&bridge_channel->features->feature_flags,
 					AST_BRIDGE_FLAG_DISSOLVE_HANGUP))) {
 			bridge_dissolve(bridge);
@@ -600,14 +599,9 @@
 /*! \brief Internal function to handle DTMF from a channel */
 static struct ast_frame *bridge_handle_dtmf(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 {
-	struct ast_bridge_features *features;
+	struct ast_bridge_features *features = bridge_channel->features;
 	struct ast_bridge_hook *hook;
 	char dtmf[2];
-
-	features = bridge_channel->features;
-	if (!features) {
-		return frame;
-	}
 
 /* BUGBUG the feature hook matching needs to be done here.  Any matching feature hook needs to be queued onto the bridge_channel.  Also the feature hook digit timeout needs to be handled. */
 /* BUGBUG the AMI atxfer action just sends DTMF end events to initiate DTMF atxfer and dial the extension.  Another reason the DTMF hook matching needs rework. */
@@ -641,27 +635,23 @@
  */
 static void bridge_handle_hangup(struct ast_bridge_channel *bridge_channel)
 {
-	struct ast_bridge_features *features;
-
-	features = bridge_channel->features;
-	if (features) {
-		struct ast_bridge_hook *hook;
-		struct ao2_iterator iter;
-
-		/* Run any hangup hooks. */
-		iter = ao2_iterator_init(features->hangup_hooks, 0);
-		for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
-			int failed;
-
-			failed = hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
-			if (failed) {
-				ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
-					hook, bridge_channel, ast_channel_name(bridge_channel->chan));
-				ao2_unlink(features->hangup_hooks, hook);
-			}
-		}
-		ao2_iterator_destroy(&iter);
-	}
+	struct ast_bridge_features *features = bridge_channel->features;
+	struct ast_bridge_hook *hook;
+	struct ao2_iterator iter;
+
+	/* Run any hangup hooks. */
+	iter = ao2_iterator_init(features->hangup_hooks, 0);
+	for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
+		int failed;
+
+		failed = hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
+		if (failed) {
+			ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
+				hook, bridge_channel, ast_channel_name(bridge_channel->chan));
+			ao2_unlink(features->hangup_hooks, hook);
+		}
+	}
+	ao2_iterator_destroy(&iter);
 
 	/* Default hangup action. */
 	ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END);
@@ -669,14 +659,9 @@
 
 static int bridge_channel_interval_ready(struct ast_bridge_channel *bridge_channel)
 {
-	struct ast_bridge_features *features;
+	struct ast_bridge_features *features = bridge_channel->features;
 	struct ast_bridge_hook *hook;
 	int ready;
-
-	features = bridge_channel->features;
-	if (!features || !features->interval_hooks) {
-		return 0;
-	}
 
 	ast_heap_wrlock(features->interval_hooks);
 	hook = ast_heap_peek(features->interval_hooks, 1);
@@ -932,7 +917,7 @@
 {
 	struct ast_frame *frame;
 
-	if (bridge_channel->features && bridge_channel->features->mute) {
+	if (bridge_channel->features->mute) {
 		frame = ast_read_noaudio(bridge_channel->chan);
 	} else {
 		frame = ast_read(bridge_channel->chan);
@@ -965,7 +950,7 @@
 		}
 		/* Fall through */
 	case AST_FRAME_DTMF_END:
-		if (bridge_channel->features && !bridge_channel->features->dtmf_passthrough) {
+		if (!bridge_channel->features->dtmf_passthrough) {
 			ast_frfree(frame);
 			return;
 		}
@@ -1886,10 +1871,6 @@
 	char dtmf[MAXIMUM_DTMF_FEATURE_STRING] = "";
 	size_t dtmf_len = 0;
 
-	if (!features) {
-		return;
-	}
-
 	/* The channel is now under our control and we don't really want any begin frames to do our DTMF matching so disable 'em at the core level */
 	ast_set_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_END_DTMF_ONLY);
 
@@ -1965,10 +1946,9 @@
 
 static void bridge_channel_talking(struct ast_bridge_channel *bridge_channel, int talking)
 {
-	struct ast_bridge_features *features;
-
-	features = bridge_channel->features;
-	if (features && features->talker_cb) {
+	struct ast_bridge_features *features = bridge_channel->features;
+
+	if (features->talker_cb) {
 		features->talker_cb(bridge_channel, features->talker_pvt_data, talking);
 	}
 }
@@ -2187,8 +2167,8 @@
 {
 	struct ast_timer *interval_timer;
 
-	if (bridge_channel->features
-		&& (interval_timer = bridge_channel->features->interval_timer)) {
+	interval_timer = bridge_channel->features->interval_timer;
+	if (interval_timer) {
 		if (ast_wait_for_input(ast_timer_fd(interval_timer), 0) == 1) {
 			ast_timer_ack(interval_timer, 1);
 			if (bridge_channel_interval_ready(bridge_channel)) {
@@ -2266,28 +2246,24 @@
  */
 static void bridge_channel_handle_join(struct ast_bridge_channel *bridge_channel)
 {
-	struct ast_bridge_features *features;
-
-	features = bridge_channel->features;
-	if (features) {
-		struct ast_bridge_hook *hook;
-		struct ao2_iterator iter;
-
-		/* Run any join hooks. */
-		iter = ao2_iterator_init(features->join_hooks, AO2_ITERATOR_UNLINK);
-		hook = ao2_iterator_next(&iter);
-		if (hook) {
-			bridge_channel_suspend(bridge_channel);
-			ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
-			do {
-				hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
-				ao2_ref(hook, -1);
-			} while ((hook = ao2_iterator_next(&iter)));
-			ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
-			bridge_channel_unsuspend(bridge_channel);
-		}
-		ao2_iterator_destroy(&iter);
-	}
+	struct ast_bridge_features *features = bridge_channel->features;
+	struct ast_bridge_hook *hook;
+	struct ao2_iterator iter;
+
+	/* Run any join hooks. */
+	iter = ao2_iterator_init(features->join_hooks, AO2_ITERATOR_UNLINK);
+	hook = ao2_iterator_next(&iter);
+	if (hook) {
+		bridge_channel_suspend(bridge_channel);
+		ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+		do {
+			hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
+			ao2_ref(hook, -1);
+		} while ((hook = ao2_iterator_next(&iter)));
+		ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+		bridge_channel_unsuspend(bridge_channel);
+	}
+	ao2_iterator_destroy(&iter);
 }
 
 /*!
@@ -2301,28 +2277,24 @@
  */
 static void bridge_channel_handle_leave(struct ast_bridge_channel *bridge_channel)
 {
-	struct ast_bridge_features *features;
-
-	features = bridge_channel->features;
-	if (features) {
-		struct ast_bridge_hook *hook;
-		struct ao2_iterator iter;
-
-		/* Run any leave hooks. */
-		iter = ao2_iterator_init(features->leave_hooks, AO2_ITERATOR_UNLINK);
-		hook = ao2_iterator_next(&iter);
-		if (hook) {
-			bridge_channel_suspend(bridge_channel);
-			ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
-			do {
-				hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
-				ao2_ref(hook, -1);
-			} while ((hook = ao2_iterator_next(&iter)));
-			ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
-			bridge_channel_unsuspend(bridge_channel);
-		}
-		ao2_iterator_destroy(&iter);
-	}
+	struct ast_bridge_features *features = bridge_channel->features;
+	struct ast_bridge_hook *hook;
+	struct ao2_iterator iter;
+
+	/* Run any leave hooks. */
+	iter = ao2_iterator_init(features->leave_hooks, AO2_ITERATOR_UNLINK);
+	hook = ao2_iterator_next(&iter);
+	if (hook) {
+		bridge_channel_suspend(bridge_channel);
+		ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+		do {
+			hook->callback(bridge_channel->bridge, bridge_channel, hook->hook_pvt);
+			ao2_ref(hook, -1);
+		} while ((hook = ao2_iterator_next(&iter)));
+		ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
+		bridge_channel_unsuspend(bridge_channel);
+	}
+	ao2_iterator_destroy(&iter);
 }
 
 /*! \brief Join a channel to a bridge and handle anything the bridge may want us to do */
@@ -3448,7 +3420,7 @@
 	struct ast_bridge_hook *hook;
 	int res;
 
-	if (!interval || !callback || !features || !features->interval_hooks) {
+	if (!features ||!interval || !callback) {
 		return -1;
 	}
 
@@ -3584,10 +3556,8 @@
  */
 static void hooks_remove_on_pull_container(struct ao2_container *hooks)
 {
-	if (hooks) {
-		ao2_callback(hooks, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
-			hook_remove_on_pull_match, NULL);
-	}
+	ao2_callback(hooks, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE,
+		hook_remove_on_pull_match, NULL);
 }
 
 /*!
@@ -3603,10 +3573,6 @@
 {
 	struct ast_bridge_hook *hook;
 	int changed;
-
-	if (!hooks) {
-		return;
-	}
 
 	ast_heap_wrlock(hooks);
 	do {
@@ -3636,10 +3602,6 @@
  */
 static void bridge_features_remove_on_pull(struct ast_bridge_features *features)
 {
-	if (!features) {
-		return;
-	}
-
 	hooks_remove_on_pull_container(features->dtmf_hooks);
 	hooks_remove_on_pull_container(features->hangup_hooks);
 	hooks_remove_on_pull_container(features->join_hooks);




More information about the asterisk-commits mailing list