[asterisk-commits] rmudgett: branch 1.8 r345546 - /branches/1.8/channels/sig_pri.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Nov 17 11:06:17 CST 2011


Author: rmudgett
Date: Thu Nov 17 11:06:14 2011
New Revision: 345546

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=345546
Log:
Remove dead code since pri_grab() can never fail.

Dead code makes programmers sick.  I am sick of looking at it.

Modified:
    branches/1.8/channels/sig_pri.c

Modified: branches/1.8/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/sig_pri.c?view=diff&rev=345546&r1=345545&r2=345546
==============================================================================
--- branches/1.8/channels/sig_pri.c (original)
+++ branches/1.8/channels/sig_pri.c Thu Nov 17 11:06:14 2011
@@ -1933,15 +1933,12 @@
 			&& !ast_matchmore_extension(chan, chan->context, exten, 1, p->cid_num)) {
 			sig_pri_lock_private(p);
 			if (p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
-					if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) {
-						p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING;
-					}
-					pri_proceeding(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 0);
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_grab(p, p->pri);
+				if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) {
+					p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING;
+				}
+				pri_proceeding(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 0);
+				pri_rel(p->pri);
 			}
 			sig_pri_unlock_private(p);
 		}
@@ -6580,10 +6577,7 @@
 		ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
 		return -1;
 	}
-	if (pri_grab(p, p->pri)) {
-		ast_log(LOG_WARNING, "Failed to grab PRI!\n");
-		return -1;
-	}
+	pri_grab(p, p->pri);
 	if (!(p->call = pri_new_call(p->pri->pri))) {
 		ast_log(LOG_WARNING, "Unable to create call on channel %d\n", p->channel);
 		pri_rel(p->pri);
@@ -6922,16 +6916,13 @@
 			chan->hangupcause = AST_CAUSE_USER_BUSY;
 			p->progress = 1;/* No need to send plain PROGRESS after this. */
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
+				pri_grab(p, p->pri);
 #ifdef HAVE_PRI_PROG_W_CAUSE
-					pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause);
+				pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause);
 #else
-					pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
+				pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
 #endif
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_rel(p->pri);
 			}
 		}
 		break;
@@ -6939,13 +6930,10 @@
 		if (p->call_level < SIG_PRI_CALL_LEVEL_ALERTING && !p->outgoing) {
 			p->call_level = SIG_PRI_CALL_LEVEL_ALERTING;
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
-					pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
-						p->no_b_channel || p->digital ? 0 : 1);
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_grab(p, p->pri);
+				pri_acknowledge(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
+					p->no_b_channel || p->digital ? 0 : 1);
+				pri_rel(p->pri);
 			}
 		}
 		res = sig_pri_play_tone(p, SIG_PRI_TONE_RINGTONE);
@@ -6959,16 +6947,13 @@
 		if (p->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING && !p->outgoing) {
 			p->call_level = SIG_PRI_CALL_LEVEL_PROCEEDING;
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
-					pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
-						p->no_b_channel || p->digital ? 0 : 1);
-					if (!p->no_b_channel && !p->digital) {
-						sig_pri_set_dialing(p, 0);
-					}
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_grab(p, p->pri);
+				pri_proceeding(p->pri->pri,p->call, PVT_TO_CHANNEL(p),
+					p->no_b_channel || p->digital ? 0 : 1);
+				if (!p->no_b_channel && !p->digital) {
+					sig_pri_set_dialing(p, 0);
+				}
+				pri_rel(p->pri);
 			}
 		}
 		/* don't continue in ast_indicate */
@@ -6981,16 +6966,13 @@
 			&& !p->no_b_channel) {
 			p->progress = 1;/* No need to send plain PROGRESS again. */
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
+				pri_grab(p, p->pri);
 #ifdef HAVE_PRI_PROG_W_CAUSE
-					pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, -1);  /* no cause at all */
+				pri_progress_with_cause(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1, -1);  /* no cause at all */
 #else
-					pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
+				pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
 #endif
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_rel(p->pri);
 			}
 		}
 		/* don't continue in ast_indicate */
@@ -7037,36 +7019,29 @@
 			}
 			p->progress = 1;/* No need to send plain PROGRESS after this. */
 			if (p->pri && p->pri->pri) {
-				if (!pri_grab(p, p->pri)) {
+				pri_grab(p, p->pri);
 #ifdef HAVE_PRI_PROG_W_CAUSE
-					pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause);
+				pri_progress_with_cause(p->pri->pri, p->call, PVT_TO_CHANNEL(p), 1, chan->hangupcause);
 #else
-					pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
+				pri_progress(p->pri->pri,p->call, PVT_TO_CHANNEL(p), 1);
 #endif
-					pri_rel(p->pri);
-				} else {
-					ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-				}
+				pri_rel(p->pri);
 			}
 		}
 		break;
 	case AST_CONTROL_HOLD:
 		if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) {
-			if (!pri_grab(p, p->pri)) {
-				res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_HOLD);
-				pri_rel(p->pri);
-			} else {
-				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->pri->span);
-			}
+			pri_grab(p, p->pri);
+			res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_HOLD);
+			pri_rel(p->pri);
 		} else
 			ast_moh_start(chan, data, p->mohinterpret);
 		break;
 	case AST_CONTROL_UNHOLD:
 		if (p->pri && !strcasecmp(p->mohinterpret, "passthrough")) {
-			if (!pri_grab(p, p->pri)) {
-				res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_RETRIEVAL);
-				pri_rel(p->pri);
-			}
+			pri_grab(p, p->pri);
+			res = pri_notify(p->pri->pri, p->call, p->prioffset, PRI_NOTIFY_REMOTE_RETRIEVAL);
+			pri_rel(p->pri);
 		} else
 			ast_moh_stop(chan);
 		break;
@@ -7078,9 +7053,10 @@
 		break;
 	case AST_CONTROL_CONNECTED_LINE:
 		ast_debug(1, "Received AST_CONTROL_CONNECTED_LINE on %s\n", chan->name);
-		if (p->pri && !pri_grab(p, p->pri)) {
+		if (p->pri) {
 			struct pri_party_connected_line connected;
 
+			pri_grab(p, p->pri);
 			memset(&connected, 0, sizeof(connected));
 			sig_pri_party_id_from_ast(&connected.id, &chan->connected.id);
 
@@ -7090,7 +7066,8 @@
 		break;
 	case AST_CONTROL_REDIRECTING:
 		ast_debug(1, "Received AST_CONTROL_REDIRECTING on %s\n", chan->name);
-		if (p->pri && !pri_grab(p, p->pri)) {
+		if (p->pri) {
+			pri_grab(p, p->pri);
 			sig_pri_redirecting_update(p, chan);
 			pri_rel(p->pri);
 		}
@@ -7101,7 +7078,8 @@
 			struct ast_aoc_decoded *decoded
 				= ast_aoc_decode((struct ast_aoc_encoded *) data, datalen, chan);
 			ast_debug(1, "Received AST_CONTROL_AOC on %s\n", chan->name);
-			if (decoded && p->pri && !pri_grab(p, p->pri)) {
+			if (decoded && p->pri) {
+				pri_grab(p, p->pri);
 				switch (ast_aoc_get_msg_type(decoded)) {
 				case AST_AOC_S:
 					if (p->pri->aoc_passthrough_flag & SIG_PRI_AOC_GRANT_S) {
@@ -7152,29 +7130,27 @@
 
 int sig_pri_answer(struct sig_pri_chan *p, struct ast_channel *ast)
 {
-	int res = 0;
+	int res;
+
 	/* Send a pri acknowledge */
-	if (!pri_grab(p, p->pri)) {
+	pri_grab(p, p->pri);
 #if defined(HAVE_PRI_AOC_EVENTS)
-		if (p->aoc_s_request_invoke_id_valid) {
-			/* if AOC-S was requested and the invoke id is still present on answer.  That means
-			 * no AOC-S rate list was provided, so send a NULL response which will indicate that
-			 * AOC-S is not available */
-			pri_aoc_s_request_response_send(p->pri->pri, p->call,
-				p->aoc_s_request_invoke_id, NULL);
-			p->aoc_s_request_invoke_id_valid = 0;
-		}
+	if (p->aoc_s_request_invoke_id_valid) {
+		/* if AOC-S was requested and the invoke id is still present on answer.  That means
+		 * no AOC-S rate list was provided, so send a NULL response which will indicate that
+		 * AOC-S is not available */
+		pri_aoc_s_request_response_send(p->pri->pri, p->call,
+			p->aoc_s_request_invoke_id, NULL);
+		p->aoc_s_request_invoke_id_valid = 0;
+	}
 #endif	/* defined(HAVE_PRI_AOC_EVENTS) */
-		if (p->call_level < SIG_PRI_CALL_LEVEL_CONNECT) {
-			p->call_level = SIG_PRI_CALL_LEVEL_CONNECT;
-		}
-		sig_pri_set_dialing(p, 0);
-		sig_pri_open_media(p);
-		res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
-		pri_rel(p->pri);
-	} else {
-		res = -1;
-	}
+	if (p->call_level < SIG_PRI_CALL_LEVEL_CONNECT) {
+		p->call_level = SIG_PRI_CALL_LEVEL_CONNECT;
+	}
+	sig_pri_set_dialing(p, 0);
+	sig_pri_open_media(p);
+	res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
+	pri_rel(p->pri);
 	ast_setstate(ast, AST_STATE_UP);
 	return res;
 }
@@ -7315,12 +7291,9 @@
 			return 0;
 		}
 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_PROCEEDING) {
-			if (!pri_grab(pvt, pvt->pri)) {
-				pri_information(pvt->pri->pri, pvt->call, digit);
-				pri_rel(pvt->pri);
-			} else {
-				ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", pvt->pri->span);
-			}
+			pri_grab(pvt, pvt->pri);
+			pri_information(pvt->pri->pri, pvt->call, digit);
+			pri_rel(pvt->pri);
 			return 0;
 		}
 		if (pvt->call_level < SIG_PRI_CALL_LEVEL_CONNECT) {
@@ -7870,14 +7843,9 @@
 		return -1;
 	}
 
-	if (!pri_grab(p, p->pri)) {
-		pri_keypad_facility(p->pri->pri, p->call, digits);
-		pri_rel(p->pri);
-	} else {
-		ast_debug(1, "Unable to grab pri to send keypad facility!\n");
-		sig_pri_unlock_private(p);
-		return -1;
-	}
+	pri_grab(p, p->pri);
+	pri_keypad_facility(p->pri->pri, p->call, digits);
+	pri_rel(p->pri);
 
 	sig_pri_unlock_private(p);
 
@@ -7896,12 +7864,9 @@
 		return -1;
 	}
 
-	if (!pri_grab(p, p->pri)) {
-		res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason);
-		pri_rel(p->pri);
-	} else {
-		ast_log(LOG_DEBUG, "Unable to grab pri to send callrerouting facility on span %d!\n", p->pri->span);
-	}
+	pri_grab(p, p->pri);
+	res = pri_callrerouting_facility(p->pri->pri, p->call, destination, original, reason);
+	pri_rel(p->pri);
 
 	sig_pri_unlock_private(p);
 




More information about the asterisk-commits mailing list