[libss7-commits] mattf: branch mattf/bug13495 r222 - /team/mattf/bug13495/mtp3.c

SVN commits to the libss7 project libss7-commits at lists.digium.com
Mon Dec 1 16:14:55 CST 2008


Author: mattf
Date: Mon Dec  1 16:14:54 2008
New Revision: 222

URL: http://svn.digium.com/view/libss7?view=rev&rev=222
Log:
Bunch of style related cleanups in mtp3.c

Modified:
    team/mattf/bug13495/mtp3.c

Modified: team/mattf/bug13495/mtp3.c
URL: http://svn.digium.com/view/libss7/team/mattf/bug13495/mtp3.c?view=diff&rev=222&r1=221&r2=222
==============================================================================
--- team/mattf/bug13495/mtp3.c (original)
+++ team/mattf/bug13495/mtp3.c Mon Dec  1 16:14:54 2008
@@ -428,15 +428,16 @@
 	int i, j, mtp3_up = 0;
 	int av_links = available_links(ss7, -1, 0);
 		
-	for (i = 0; i < ss7->numsps; i++)
+	for (i = 0; i < ss7->numsps; i++) {
 		if (ss7->adj_sps[i]->state == MTP3_UP) {
 			mtp3_up = 1;
 			break;
 		}
+	}
 	
 	if (!av_links && mtp3_up) {
 		/* find a locally inhibited link */
-		for (i = 0; i < ss7->numlinks; i++)
+		for (i = 0; i < ss7->numlinks; i++) {
 			if (ss7->links[i]->inhibit & INHIBITED_LOCALLY) {
 				if (!(ss7->links[i]->got_sent_netmsg & SENT_LUN)) {
 					AUTORL(rl, ss7->links[i]);
@@ -447,9 +448,10 @@
 					i = ss7->numlinks; /* in this case force remote uninhibit too ! */
 				break;
 			}
+		}
 		/* try force uninhibit */
-		if (i == ss7->numlinks)
-			for (i = 0; i < ss7->numlinks; i++)
+		if (i == ss7->numlinks) {
+			for (i = 0; i < ss7->numlinks; i++) {
 				if (ss7->links[i]->inhibit & INHIBITED_REMOTELY) {
 					if (!(ss7->links[i]->got_sent_netmsg & SENT_LFU))
 						break;
@@ -458,6 +460,8 @@
 					ss7_message(ss7, "Forced uninhibiting remotely inhibited link (no more signalling links are in service) SLC: %i ADJPC: %i\n", ss7->links[i]->slc, ss7->links[i]->dpc);
 					break;
 				}
+			}
+		}
 	}
 	
 	if (ss7->state != SS7_STATE_UP && mtp3_up) {
@@ -497,9 +501,10 @@
 						link->changeover = NO_CHANGEOVER;
 					
 					mtp3_free_co(link);
-					for (j = 0; j < MTP3_MAX_TIMERS; j++)
+					for (j = 0; j < MTP3_MAX_TIMERS; j++) {
 						if (link->mtp3_timer[j] > -1)
 							ss7_schedule_del(ss7, &link->mtp3_timer[j]);
+					}
 					
 				}
 				
@@ -583,8 +588,7 @@
 				if (dst) {
 					dst->next = cur;
 					dst = dst->next;
-				}
-				else {
+				} else {
 					*to = cur;
 					dst = cur;
 				}
@@ -653,9 +657,10 @@
 	struct ss7 *ss7 = adj_sp->master;
 	int i, count = 0;
 	
-	for (i = 0; i < adj_sp->numlinks; i++)
+	for (i = 0; i < adj_sp->numlinks; i++) {
 		if (adj_sp->links[i]->std_test_passed)
 			count++;
+	}
 	
 	if (!count && adj_sp->state != MTP3_DOWN) {
 		adj_sp->state = MTP3_DOWN;
@@ -716,9 +721,10 @@
 	
 	mtp3_destroy_all_routes(adj_sp);
 	
-	for (i = 0; i < adj_sp->numlinks; i++)
+	for (i = 0; i < adj_sp->numlinks; i++) {
 		if (!mtp3_init(adj_sp->links[i]))
 			break;
+	}
 	
 	ss7_check(link->master);
 }
@@ -1263,13 +1269,13 @@
 
 	link->mtp3_timer[MTP3_TIMER_T2] = -1;
 	link->got_sent_netmsg &= ~(SENT_COO | SENT_ECO);
-    mtp3_move_buffer(link->master, link, &link->co_tx_q, &tmp, -1, -1);
-    mtp3_move_buffer(link->master, link, &link->co_buf, &tmp, -1, -1);
-    mtp3_transmit_buffer(link->master, &tmp);
-    link->changeover = CHANGEOVER_COMPLETED;
-    mtp3_free_co(link);
-    mtp3_check(link->adj_sp);
-    ss7_message(link->master, "MTP3 T2 timer expired on link SLC: %i ADJPC: %i changeover completed\n",
+	mtp3_move_buffer(link->master, link, &link->co_tx_q, &tmp, -1, -1);
+	mtp3_move_buffer(link->master, link, &link->co_buf, &tmp, -1, -1);
+	mtp3_transmit_buffer(link->master, &tmp);
+	link->changeover = CHANGEOVER_COMPLETED;
+	mtp3_free_co(link);
+	mtp3_check(link->adj_sp);
+	ss7_message(link->master, "MTP3 T2 timer expired on link SLC: %i ADJPC: %i changeover completed\n",
     		link->slc, link->dpc);
 }
 
@@ -1277,6 +1283,7 @@
 {
 	struct mtp2 *link = data;
 	struct ss7 *ss7 = link->master;
+
 	link->mtp3_timer[MTP3_TIMER_T5] = -1;
 	link->got_sent_netmsg &= ~SENT_CBD;
 	ss7_message(ss7, "MTP3 T5 timer expired on link SLC: %i ADJPC: %i\n", link->slc, link->dpc);
@@ -1437,9 +1444,9 @@
 			if (ss7->mtp3_timers[MTP3_TIMER_T2]) {
 				if (link->mtp3_timer[MTP3_TIMER_T2] > -1)
 					ss7_schedule_del(ss7, &link->mtp3_timer[MTP3_TIMER_T2]);
-					link->mtp3_timer[MTP3_TIMER_T2] = ss7_schedule_event(ss7, ss7->mtp3_timers[MTP3_TIMER_T2], &mtp3_t2_expired, link);
-					ss7_message(ss7, "MTP3 T2 timer started on link SLC: %i ADJPC: %i\n", link->slc, link->dpc);
-				}
+				link->mtp3_timer[MTP3_TIMER_T2] = ss7_schedule_event(ss7, ss7->mtp3_timers[MTP3_TIMER_T2], &mtp3_t2_expired, link);
+				ss7_message(ss7, "MTP3 T2 timer started on link SLC: %i ADJPC: %i\n", link->slc, link->dpc);
+			}
 			ss7_msg_userpart_len(m, rllen + 1); /* no more params */
 			break;
 		case NET_MNG_ECA:
@@ -1491,11 +1498,12 @@
 			}
 		}
 		
-		for (i = 0; i < ss7->numlinks; i++)
+		for (i = 0; i < ss7->numlinks; i++) {
 			if (ss7->links[i]->std_test_passed && ss7->links[i] != link) {
 				rl.sls = ss7->links[i]->slc;
 				return mtp3_transmit(ss7, SIG_NET_MNG, rl, m);
 			}
+		}
 		
 	} else if (can_reroute == 1) { /* 1st try to send COO, CBD, ECO via another link */
 		for (i = 0; i < ss7->numlinks; i++)
@@ -1511,13 +1519,15 @@
 		if (link->std_test_passed) {
 			rl.sls = link->slc;
 			return mtp3_transmit(ss7, SIG_NET_MNG, rl, m);
-		} else
+		} else {
 			/* we may use another link to the same adjecent sp */
-			for (i = 0; i < link->adj_sp->numlinks; i++)
+			for (i = 0; i < link->adj_sp->numlinks; i++) {
 				if (link->adj_sp->links[i]->std_test_passed) {
 					rl.sls = link->adj_sp->links[i]->slc;
 					return mtp3_transmit(ss7, SIG_NET_MNG, rl, m);
 				}
+			}
+		}
 		
 	}
 
@@ -1624,7 +1634,7 @@
 				}
 			}
 			if (mtp2->adj_sp->state == MTP3_DOWN)
-					return mtp3_init(mtp2);
+				return mtp3_init(mtp2);
 		} else {
 			ss7_error(ss7, "Missmatch the SLTA on link SLC: %i ADJPC %i\n", mtp2->slc, mtp2->dpc);
 			mtp2->std_test_passed = 0;
@@ -1791,8 +1801,8 @@
 static struct mtp2 * slc_to_mtp2(struct ss7 *ss7, unsigned int slc)
 {
 	int i = 0;
-
 	struct mtp2 *link = NULL;
+
 	for (i = 0; i < ss7->numlinks; i++) {
 		if (ss7->links[i]->slc == slc)
 			link = ss7->links[i];
@@ -1829,11 +1839,12 @@
 {
 	int i;
 
-	for (i = 0; i < ss7->numlinks; i++)
+	for (i = 0; i < ss7->numlinks; i++) {
 		if ((ss7->mtp2_linkstate[i] == MTP2_LINKSTATE_DOWN)) {
 			mtp2_start(ss7->links[i], 1);
 			ss7->mtp2_linkstate[i] = MTP2_LINKSTATE_ALIGNING;
 		}
+	}
 	
 	return;
 }
@@ -1923,10 +1934,10 @@
 	else
 		return "Unknown msg\n";
 
-		AUTORL(rl, link);
-		net_mng_send(link, h0h1, rl, param);
-
-		return "OK\n";
+	AUTORL(rl, link);
+	net_mng_send(link, h0h1, rl, param);
+
+	return "OK\n";
 }
 
 int ss7_set_mtp3_timer(struct ss7 *ss7, char *name, int ms)
@@ -2015,11 +2026,12 @@
 	link->adj_sp = adj_sp;
 	adj_sp->numlinks++;
 	
-	for (i = 0; i < adj_sp->numlinks; i++)
+	for (i = 0; i < adj_sp->numlinks; i++) {
 		if (!adj_sp->links[i]) {
 			adj_sp->links[i] = link;
 			break;
 		}
+	}
 }
 
 static inline void mtp3_new_adjsp(struct ss7 *ss7, struct mtp2 *link)




More information about the libss7-commits mailing list