[asterisk-commits] coreyfarrell: branch coreyfarrell/chan_sip-14 r419878 - in /team/coreyfarrell...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jul 31 15:57:19 CDT 2014


Author: coreyfarrell
Date: Thu Jul 31 15:57:14 2014
New Revision: 419878

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419878
Log:
fix missing braces for if/while

Modified:
    team/coreyfarrell/chan_sip-14/channels/chan_sip.c
    team/coreyfarrell/chan_sip-14/channels/sip/config_parser.c
    team/coreyfarrell/chan_sip-14/channels/sip/dialplan_functions.c
    team/coreyfarrell/chan_sip-14/channels/sip/reqresp_parser.c

Modified: team/coreyfarrell/chan_sip-14/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/coreyfarrell/chan_sip-14/channels/chan_sip.c?view=diff&rev=419878&r1=419877&r2=419878
==============================================================================
--- team/coreyfarrell/chan_sip-14/channels/chan_sip.c (original)
+++ team/coreyfarrell/chan_sip-14/channels/chan_sip.c Thu Jul 31 15:57:14 2014
@@ -1099,12 +1099,14 @@
 
 /*! some list management macros. */
 
-#define UNLINK(element, head, prev) do {	\
-	if (prev)				\
-		(prev)->next = (element)->next;	\
-	else					\
-		(head) = (element)->next;	\
-	} while (0)
+#define UNLINK(element, head, prev) \
+do { \
+	if (prev) { \
+		(prev)->next = (element)->next; \
+	} else { \
+		(head) = (element)->next; \
+	} \
+} while (0)
 
 struct ao2_container *sip_monitor_instances;
 
@@ -2332,25 +2334,27 @@
 
 struct sip_pvt *dialog_ref_debug(struct sip_pvt *p, const char *tag, char *file, int line, const char *func)
 {
-	if (p)
+	if (p) {
 #ifdef REF_DEBUG
 		__ao2_ref_debug(p, 1, tag, file, line, func);
 #else
 		ao2_ref(p, 1);
 #endif
-	else
+	} else {
 		ast_log(LOG_ERROR, "Attempt to Ref a null pointer\n");
+	}
 	return p;
 }
 
 struct sip_pvt *dialog_unref_debug(struct sip_pvt *p, const char *tag, char *file, int line, const char *func)
 {
-	if (p)
+	if (p) {
 #ifdef REF_DEBUG
 		__ao2_ref_debug(p, -1, tag, file, line, func);
 #else
 		ao2_ref(p, -1);
 #endif
+	}
 	return NULL;
 }
 
@@ -2444,9 +2448,9 @@
  */
 #define check_request_transport(peer, tmpl) ({ \
 	int ret = 0; \
-	if (peer->socket.type == tmpl->socket.type) \
+	if (peer->socket.type == tmpl->socket.type) { \
 		; \
-	else if (!(peer->transports & tmpl->socket.type)) {\
+	} else if (!(peer->transports & tmpl->socket.type)) {\
 		ast_log(LOG_ERROR, \
 			"'%s' is not a valid transport for '%s'. we only use '%s'! ending call.\n", \
 			sip_get_transport(tmpl->socket.type), peer->name, get_transport_list(peer->transports) \
@@ -3303,17 +3307,19 @@
 #ifdef REF_DEBUG
 struct sip_peer *_ref_peer(struct sip_peer *peer, char *tag, char *file, int line, const char *func)
 {
-	if (peer)
+	if (peer) {
 		__ao2_ref_debug(peer, 1, tag, file, line, func);
-	else
+	} else {
 		ast_log(LOG_ERROR, "Attempt to Ref a null peer pointer\n");
+	}
 	return peer;
 }
 
 void *_unref_peer(struct sip_peer *peer, char *tag, char *file, int line, const char *func)
 {
-	if (peer)
+	if (peer) {
 		__ao2_ref_debug(peer, -1, tag, file, line, func);
+	}
 	return NULL;
 }
 #else
@@ -4557,8 +4563,9 @@
 				p->pendinginvite = 0;
 			}
 			if (cur->retransid > -1) {
-				if (sipdebug)
+				if (sipdebug) {
 					ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
+				}
 			}
 			/* This odd section is designed to thwart a
 			 * race condition in the packet scheduler. There are
@@ -4624,8 +4631,9 @@
 			(cur->is_resp || method_match(sipmethod, ast_str_buffer(cur->data)))) {
 			/* this is our baby */
 			if (cur->retransid > -1) {
-				if (sipdebug)
+				if (sipdebug) {
 					ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
+				}
 			}
 			AST_SCHED_DEL(sched, cur->retransid);
 			res = TRUE;
@@ -5007,8 +5015,9 @@
 	char last_char = '\0';
 	const char *s;
 	for (s = start; *s && s != lim; last_char = *s++) {
-		if (*s == '"' && last_char != '\\')
+		if (*s == '"' && last_char != '\\') {
 			break;
+		}
 	}
 	return s;
 }
@@ -5018,13 +5027,15 @@
 {
 	struct sip_pvt *p = ast_channel_tech_pvt(chan);
 
-	if (subclass != AST_HTML_URL)
+	if (subclass != AST_HTML_URL) {
 		return -1;
+	}
 
 	ast_string_field_build(p, url, "<%s>;mode=active", data);
 
-	if (sip_debug_test_pvt(p))
+	if (sip_debug_test_pvt(p)) {
 		ast_debug(1, "Send URL %s, state = %u!\n", data, ast_channel_state(chan));
+	}
 
 	switch (ast_channel_state(chan)) {
 	case AST_STATE_RING:
@@ -5176,8 +5187,9 @@
 	 * the name of the global regexten context, if not specified
 	 * individually.
 	 */
-	if (ast_strlen_zero(sip_cfg.regcontext))
+	if (ast_strlen_zero(sip_cfg.regcontext)) {
 		return;
+	}
 
 	ast_copy_string(multi, S_OR(peer->regexten, peer->name), sizeof(multi));
 	stringp = multi;
@@ -5216,8 +5228,9 @@
 {
 	struct sip_mailbox *mailbox;
 
-	while ((mailbox = AST_LIST_REMOVE_HEAD(&peer->mailboxes, entry)))
+	while ((mailbox = AST_LIST_REMOVE_HEAD(&peer->mailboxes, entry))) {
 		destroy_mailbox(mailbox);
+	}
 }
 
 static void sip_destroy_peer_fn(void *peer)
@@ -5262,13 +5275,14 @@
 	register_peer_exten(peer, FALSE);
 	ast_free_acl_list(peer->acl);
 	ast_free_acl_list(peer->directmediaacl);
-	if (peer->selfdestruct)
+	if (peer->selfdestruct) {
 		ast_atomic_fetchadd_int(&apeerobjs, -1);
-	else if (!ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS) && peer->is_realtime) {
+	} else if (!ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS) && peer->is_realtime) {
 		ast_atomic_fetchadd_int(&rpeerobjs, -1);
 		ast_debug(3, "-REALTIME- peer Destroyed. Name: %s. Realtime Peer objects: %d\n", peer->name, rpeerobjs);
-	} else
+	} else {
 		ast_atomic_fetchadd_int(&speerobjs, -1);
+	}
 	if (peer->auth) {
 		ao2_t_ref(peer->auth, -1, "Removing peer authentication");
 		peer->auth = NULL;
@@ -5812,15 +5826,17 @@
 	struct ast_control_t38_parameters parameters = { .request_response = 0 };
 
 	/* Don't bother changing if we are already in the state wanted */
-	if (old == state)
+	if (old == state) {
 		return;
+	}
 
 	p->t38.state = state;
 	ast_debug(2, "T38 state changed to %u on channel %s\n", p->t38.state, chan ? ast_channel_name(chan) : "<none>");
 
 	/* If no channel was provided we can't send off a control frame */
-	if (!chan)
+	if (!chan) {
 		return;
+	}
 
 	/* Given the state requested and old state determine what control frame we want to queue up */
 	switch (state) {
@@ -5850,8 +5866,9 @@
 	}
 
 	/* Woot we got a message, create a control frame and send it on! */
-	if (parameters.request_response)
+	if (parameters.request_response) {
 		ast_queue_control_data(chan, AST_CONTROL_T38_PARAMETERS, &parameters, sizeof(parameters));
+	}
 }
 
 /*! \brief Set the global T38 capabilities on a SIP dialog structure */
@@ -6019,16 +6036,18 @@
 	/* this checks that the dialog is contacting the peer on a valid
 	 * transport type based on the peers transport configuration,
 	 * otherwise, this function bails out */
-	if (dialog->socket.type && check_request_transport(peer, dialog))
+	if (dialog->socket.type && check_request_transport(peer, dialog)) {
 		return -1;
+	}
 	copy_socket_data(&dialog->socket, &peer->socket);
 
 	if (!(ast_sockaddr_isnull(&peer->addr) && ast_sockaddr_isnull(&peer->defaddr)) &&
 	    (!peer->maxms || ((peer->lastms >= 0)  && (peer->lastms <= peer->maxms)))) {
 		dialog->sa = ast_sockaddr_isnull(&peer->addr) ? peer->defaddr : peer->addr;
 		dialog->recv = dialog->sa;
-	} else
+	} else {
 		return -1;
+	}
 
 	/* XXX TODO: get flags directly from peer only as they are needed using dialog->relatedpeer */
 	ast_copy_flags(&dialog->flags[0], &peer->flags[0], SIP_FLAGS_TO_COPY);
@@ -6114,8 +6133,9 @@
 	dialog->maxcallbitrate = peer->maxcallbitrate;
 	dialog->disallowed_methods = peer->disallowed_methods;
 	ast_cc_copy_config_params(dialog->cc_params, peer->cc_params);
-	if (ast_strlen_zero(dialog->tohost))
+	if (ast_strlen_zero(dialog->tohost)) {
 		ast_string_field_set(dialog, tohost, ast_sockaddr_stringify_host_remote(&dialog->sa));
+	}
 	if (!ast_strlen_zero(peer->fromdomain)) {
 		ast_string_field_set(dialog, fromdomain, peer->fromdomain);
 		if (!dialog->initreq.headers) {
@@ -6211,8 +6231,9 @@
 	peername2 = ast_strdupa(opeer);
 	AST_NONSTANDARD_RAW_ARGS(hostport, peername2, ':');
 
-	if (hostport.port)
+	if (hostport.port) {
 		dialog->portinuri = 1;
+	}
 
 	dialog->timer_t1 = global_t1; /* Default SIP retransmission timer T1 (RFC 3261) */
 	dialog->timer_b = global_timer_b; /* Default SIP transaction timer B (RFC 3261) */
@@ -6282,8 +6303,9 @@
 		}
 	}
 
-	if (!dialog->socket.type)
+	if (!dialog->socket.type) {
 		set_socket_transport(&dialog->socket, AST_TRANSPORT_UDP);
+	}
 	if (!dialog->socket.port) {
 		dialog->socket.port = htons(ast_sockaddr_port(&bindaddr));
 	}
@@ -6420,11 +6442,13 @@
 		char buf[SIPBUFSIZE / 2];
 
 		if (referer) {
-			if (sipdebug)
+			if (sipdebug) {
 				ast_debug(3, "Call for %s transferred by %s\n", p->username, referer);
+			}
 			snprintf(buf, sizeof(buf)-1, "-> %s (via %s)", p->cid_name, referer);
-		} else
+		} else {
 			snprintf(buf, sizeof(buf)-1, "-> %s", p->cid_name);
+		}
 		ast_string_field_set(p, cid_name, buf);
 	}
 	ast_debug(1, "Outgoing Call for %s\n", p->username);
@@ -6552,8 +6576,9 @@
 		p->stimer = NULL;
 	}
 
-	if (sip_debug_test_pvt(p))
+	if (sip_debug_test_pvt(p)) {
 		ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text);
+	}
 
 	if (ast_test_flag(&p->flags[0], SIP_INC_COUNT) || ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
 		update_call_counter(p, DEC_CALL_LIMIT);
@@ -6562,30 +6587,36 @@
 
 	/* Unlink us from the owner if we have one */
 	if (p->owner) {
-		if (lockowner)
+		if (lockowner) {
 			ast_channel_lock(p->owner);
+		}
 		ast_debug(1, "Detaching from %s\n", ast_channel_name(p->owner));
 		ast_channel_tech_pvt_set(p->owner, NULL);
 		/* Make sure that the channel knows its backend is going away */
 		ast_channel_softhangup_internal_flag_add(p->owner, AST_SOFTHANGUP_DEV);
-		if (lockowner)
+		if (lockowner) {
 			ast_channel_unlock(p->owner);
+		}
 		/* Give the channel a chance to react before deallocation */
 		usleep(1);
 	}
 
 	/* Remove link from peer to subscription of MWI */
-	if (p->relatedpeer && p->relatedpeer->mwipvt == p)
+	if (p->relatedpeer && p->relatedpeer->mwipvt == p) {
 		p->relatedpeer->mwipvt = dialog_unref(p->relatedpeer->mwipvt, "delete ->relatedpeer->mwipvt");
-	if (p->relatedpeer && p->relatedpeer->call == p)
+	}
+	if (p->relatedpeer && p->relatedpeer->call == p) {
 		p->relatedpeer->call = dialog_unref(p->relatedpeer->call, "unset the relatedpeer->call field in tandem with relatedpeer field itself");
-
-	if (p->relatedpeer)
+	}
+
+	if (p->relatedpeer) {
 		p->relatedpeer = sip_unref_peer(p->relatedpeer,"unsetting a dialog relatedpeer field in sip_destroy");
+	}
 
 	if (p->registry) {
-		if (p->registry->call == p)
+		if (p->registry->call == p) {
 			p->registry->call = dialog_unref(p->registry->call, "nulling out the registry's call dialog field in unlink_all");
+		}
 		ao2_t_replace(p->registry, NULL, "delete p->registry");
 	}
 
@@ -6594,8 +6625,9 @@
 		p->mwi = NULL;
 	}
 
-	if (dumphistory)
+	if (dumphistory) {
 		sip_dump_history(p);
+	}
 
 	if (p->options) {
 		if (p->options->outboundproxy) {
@@ -6749,8 +6781,9 @@
 
 	/* Test if we need to check call limits, in order to avoid
 	   realtime lookups if we do not need it */
-	if (!ast_test_flag(&fup->flags[0], SIP_CALL_LIMIT) && !ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD))
+	if (!ast_test_flag(&fup->flags[0], SIP_CALL_LIMIT) && !ast_test_flag(&fup->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
 		return 0;
+	}
 
 	ast_copy_string(name, fup->username, sizeof(name));
 
@@ -6814,8 +6847,9 @@
 			ao2_unlock(p);
 			sip_pvt_unlock(fup);
 		}
-		if (sipdebug)
+		if (sipdebug) {
 			ast_debug(2, "Call %s %s '%s' removed from call limit %d\n", outgoing ? "to" : "from", "peer", name, *call_limit);
+		}
 		break;
 
 	case INC_CALL_RINGING:
@@ -7104,13 +7138,15 @@
 	}
 
 	/* Store hangupcause locally in PVT so we still have it before disconnect */
-	if (p->owner)
+	if (p->owner) {
 		p->hangupcause = ast_channel_hangupcause(p->owner);
+	}
 
 	if (ast_test_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER)) {
 		if (ast_test_flag(&p->flags[0], SIP_INC_COUNT) || ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
-			if (sipdebug)
+			if (sipdebug) {
 				ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+			}
 			update_call_counter(p, DEC_CALL_LIMIT);
 		}
 		ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
@@ -7131,8 +7167,9 @@
 
 	sip_pvt_lock(p);
 	if (ast_test_flag(&p->flags[0], SIP_INC_COUNT) || ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) {
-		if (sipdebug)
+		if (sipdebug) {
 			ast_debug(1, "update_call_counter(%s) - decrement call limit counter on hangup\n", p->username);
+		}
 		update_call_counter(p, DEC_CALL_LIMIT);
 	}
 
@@ -7166,10 +7203,11 @@
 	   (Sorry, mother-in-law, you can't deny a hangup by sending
 	   603 declined to BYE...)
 	*/
-	if (p->alreadygone)
+	if (p->alreadygone) {
 		needdestroy = 1;	/* Set destroy flag at end of this function */
-	else if (p->invitestate != INV_CALLING)
+	} else if (p->invitestate != INV_CALLING) {
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+	}
 
 	/* Start the process if it's not already started */
 	if (!p->alreadygone && p->initreq.data && ast_str_strlen(p->initreq.data)) {
@@ -7199,10 +7237,11 @@
 			} else {	/* Incoming call, not up */
 				const char *res;
 				AST_SCHED_DEL_UNREF(sched, p->provisional_keepalive_sched_id, dialog_unref(p, "when you delete the provisional_keepalive_sched_id, you should dec the refcount for the stored dialog ptr"));
-				if (p->hangupcause && (res = hangup_cause2sip(p->hangupcause)))
+				if (p->hangupcause && (res = hangup_cause2sip(p->hangupcause))) {
 					transmit_response_reliable(p, res, &p->initreq);
-				else
+				} else {
 					transmit_response_reliable(p, "603 Declined", &p->initreq);
+				}
 				p->invitestate = INV_TERMINATED;
 			}
 		} else {	/* Call is in UP state, send BYE */
@@ -7511,16 +7550,19 @@
 	int ret = -1;
 	struct sip_pvt *p;
 
-	if (newchan && ast_test_flag(ast_channel_flags(newchan), AST_FLAG_ZOMBIE))
+	if (newchan && ast_test_flag(ast_channel_flags(newchan), AST_FLAG_ZOMBIE)) {
 		ast_debug(1, "New channel is zombie\n");
-	if (oldchan && ast_test_flag(ast_channel_flags(oldchan), AST_FLAG_ZOMBIE))
+	}
+	if (oldchan && ast_test_flag(ast_channel_flags(oldchan), AST_FLAG_ZOMBIE)) {
 		ast_debug(1, "Old channel is zombie\n");
+	}
 
 	if (!newchan || !ast_channel_tech_pvt(newchan)) {
-		if (!newchan)
+		if (!newchan) {
 			ast_log(LOG_WARNING, "No new channel! Fixup of %s failed.\n", ast_channel_name(oldchan));
-		else
+		} else {
 			ast_log(LOG_WARNING, "No SIP tech_pvt! Fixup of %s failed.\n", ast_channel_name(oldchan));
+		}
 		return -1;
 	}
 	p = ast_channel_tech_pvt(newchan);
@@ -7528,9 +7570,9 @@
 	sip_pvt_lock(p);
 	append_history(p, "Masq", "Old channel: %s\n", ast_channel_name(oldchan));
 	append_history(p, "Masq (cont)", "...new owner: %s\n", ast_channel_name(newchan));
-	if (p->owner != oldchan)
+	if (p->owner != oldchan) {
 		ast_log(LOG_WARNING, "old channel wasn't %p but was %p\n", oldchan, p->owner);
-	else {
+	} else {
 		sip_set_owner(p, newchan);
 		/* Re-invite RTP back to Asterisk. Needed if channel is masqueraded out of a native
 		   RTP bridge (i.e., RTP not going through Asterisk): RTP bridge code might not be
@@ -7564,8 +7606,9 @@
 		res = -1; /* Tell Asterisk to generate inband indications */
 		break;
 	case SIP_DTMF_RFC2833:
-		if (p->rtp)
+		if (p->rtp) {
 			ast_rtp_instance_dtmf_begin(p->rtp, digit);
+		}
 		break;
 	default:
 		break;
@@ -7595,8 +7638,9 @@
 		transmit_info_with_digit(p, digit, duration);
 		break;
 	case SIP_DTMF_RFC2833:
-		if (p->rtp)
+		if (p->rtp) {
 			ast_rtp_instance_dtmf_end_with_duration(p->rtp, digit, duration);
+		}
 		break;
 	case SIP_DTMF_INBAND:
 		res = -1; /* Tell Asterisk to stop inband indications */
@@ -7619,13 +7663,16 @@
 		return -1;
 	}
 
-	if (dest == NULL)	/* functions below do not take a NULL */
+	if (dest == NULL) {
+		/* functions below do not take a NULL */
 		dest = "";
+	}
 	sip_pvt_lock(p);
-	if (ast_channel_state(ast) == AST_STATE_RING)
+	if (ast_channel_state(ast) == AST_STATE_RING) {
 		res = sip_sipredirect(p, dest);
-	else
+	} else {
 		res = transmit_refer(p, dest);
+	}
 	sip_pvt_unlock(p);
 	return res;
 }
@@ -7687,8 +7734,9 @@
 			AST_SCHED_DEL_UNREF(sched, p->t38id, dialog_unref(p, "when you delete the t38id sched, you should dec the refcount for the stored dialog ptr"));
 			change_t38_state(p, T38_REJECTED);
 			transmit_response_reliable(p, "488 Not acceptable here", &p->initreq);
-		} else if (p->t38.state == T38_ENABLED)
+		} else if (p->t38.state == T38_ENABLED) {
 			transmit_reinvite_with_sdp(p, FALSE, FALSE);
+		}
 		break;
 	case AST_T38_REQUEST_PARMS: {		/* Application wants remote's parameters re-sent */
 		struct ast_control_t38_parameters parameters = p->t38.their_parms;
@@ -7835,8 +7883,9 @@
 				/* Send 180 ringing if out-of-band seems reasonable */
 				transmit_provisional_response(p, "180 Ringing", &p->initreq, 0);
 				ast_set_flag(&p->flags[0], SIP_RINGING);
-				if (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) != SIP_PROG_INBAND_YES)
+				if (ast_test_flag(&p->flags[0], SIP_PROG_INBAND) != SIP_PROG_INBAND_YES) {
 					break;
+				}
 			} else {
 				/* Well, if it's not reasonable, just send in-band */
 			}
@@ -8124,19 +8173,21 @@
 	   We also check for vrtp. If it's not there, we are not allowed do any video anyway.
 	 */
 	if (i->vrtp) {
-		if (ast_test_flag(&i->flags[1], SIP_PAGE2_VIDEOSUPPORT))
+		if (ast_test_flag(&i->flags[1], SIP_PAGE2_VIDEOSUPPORT)) {
 			needvideo = 1;
-		else if (ast_format_cap_count(i->prefcaps))
+		} else if (ast_format_cap_count(i->prefcaps)) {
 			needvideo = ast_format_cap_has_type(i->prefcaps, AST_MEDIA_TYPE_VIDEO);	/* Outbound call */
-		else
+		} else {
 			needvideo = ast_format_cap_has_type(i->jointcaps, AST_MEDIA_TYPE_VIDEO);	/* Inbound call */
+		}
 	}
 
 	if (i->trtp) {
-		if (ast_format_cap_count(i->prefcaps))
+		if (ast_format_cap_count(i->prefcaps)) {
 			needtext = ast_format_cap_has_type(i->prefcaps, AST_MEDIA_TYPE_TEXT);	/* Outbound call */
-		else
+		} else {
 			needtext = ast_format_cap_has_type(i->jointcaps, AST_MEDIA_TYPE_TEXT);	/* Inbound call */
+		}
 	}
 
 	if (needvideo) {
@@ -8386,8 +8437,9 @@
 	int x;
 
 	for (x = 0; x < ARRAY_LEN(aliases); x++) {
-		if (!strcasecmp(aliases[x].fullname, name))
+		if (!strcasecmp(aliases[x].fullname, name)) {
 			return aliases[x].shortname;
+		}
 	}
 
 	return _default;
@@ -8401,8 +8453,9 @@
 	if (strlen(name) == 1) {
 		/* We have a short header name to convert. */
 		for (x = 0; x < ARRAY_LEN(aliases); ++x) {
-			if (!strcasecmp(aliases[x].shortname, name))
+			if (!strcasecmp(aliases[x].shortname, name)) {
 				return aliases[x].fullname;
+			}
 		}
 	}
 
@@ -8770,8 +8823,9 @@
 		return p->stimer;
 	}
 
-	if (!(stp = ast_calloc(1, sizeof(struct sip_st_dlg))))
+	if (!(stp = ast_calloc(1, sizeof(struct sip_st_dlg)))) {
 		return NULL;
+	}
 
 	p->stimer = stp;
 
@@ -8798,8 +8852,9 @@
 {
 	struct sip_pvt *p;
 
-	if (!(p = ao2_t_alloc(sizeof(*p), sip_destroy_fn, "allocate a dialog(pvt) struct")))
+	if (!(p = ao2_t_alloc(sizeof(*p), sip_destroy_fn, "allocate a dialog(pvt) struct"))) {
 		return NULL;
+	}
 
 	if (ast_string_field_init(p, 512)) {
 		ao2_t_ref(p, -1, "failed to string_field_init, drop p");
@@ -8920,10 +8975,11 @@
 		p->fromdomainport = default_fromdomainport;
 	}
 	build_via(p);
-	if (!callid)
+	if (!callid) {
 		build_callid_pvt(p);
-	else
+	} else {
 		ast_string_field_set(p, callid, callid);
+	}
 	/* Assign default music on hold class */
 	ast_string_field_set(p, mohinterpret, default_mohinterpret);
 	ast_string_field_set(p, mohsuggest, default_mohsuggest);
@@ -9352,8 +9408,9 @@
 		   For Asterisk to behave correctly, you need to turn on pedanticsipchecking
 		   in sip.conf
 		   */
-		if (gettag(req, "To", totag, sizeof(totag)))
+		if (gettag(req, "To", totag, sizeof(totag))) {
 			req->has_to_tag = 1;	/* Used in handle_request/response */
+		}
 		gettag(req, "From", fromtag, sizeof(fromtag));
 
 		ast_debug(5, "= Looking for  Call ID: %s (Checking %s) --From tag %s --To-tag %s  \n", callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
@@ -9513,8 +9570,9 @@
 	}
 	/* We do not respond to responses for dialogs that we don't know about, we just drop
 	   the session quickly */
-	if (intended_method == SIP_RESPONSE)
+	if (intended_method == SIP_RESPONSE) {
 		ast_debug(2, "That's odd...  Got a response on a call we don't know about. Callid %s\n", callid ? callid : "<unknown>");
+	}
 
 	return NULL;
 }
@@ -9747,8 +9805,9 @@
 		/* Check for end-of-line */
 		if (msgbuf[h] == '\n') {
 			/* Check for end-of-message */
-			if (h + 1 == len)
+			if (h + 1 == len) {
 				break;
+			}
 			/* Check for a continuation line */
 			if (msgbuf[h + 1] == ' ' || msgbuf[h + 1] == '\t') {
 				/* Merge continuation line */
@@ -9770,8 +9829,9 @@
 			continue;
 		}
 		msgbuf[t++] = msgbuf[h++];
-		if (lws)
+		if (lws) {
 			lws = 0;
+		}
 	}
 	msgbuf[t] = '\0';
 	data->used = t;
@@ -9900,8 +9960,9 @@
 
 		/* Content-Length of zero means there can't possibly be an
 		   SDP here, even if the Content-Type says there is */
-		if (x == 0)
+		if (x == 0) {
 			return 0;
+		}
 	}
 
 	content_type = sip_get_header(req, "Content-Type");
@@ -9914,19 +9975,22 @@
 	}
 
 	/* if it's not multipart/mixed, there cannot be an SDP */
-	if (strncasecmp(content_type, "multipart/mixed", 15))
+	if (strncasecmp(content_type, "multipart/mixed", 15)) {
 		return 0;
+	}
 
 	/* if there is no boundary marker, it's invalid */
-	if ((search = strcasestr(content_type, ";boundary=")))
+	if ((search = strcasestr(content_type, ";boundary="))) {
 		search += 10;
-	else if ((search = strcasestr(content_type, "; boundary=")))
+	} else if ((search = strcasestr(content_type, "; boundary="))) {
 		search += 11;
-	else
+	} else {
 		return 0;
-
-	if (ast_strlen_zero(search))
+	}
+
+	if (ast_strlen_zero(search)) {
 		return 0;
+	}
 
 	/* If the boundary is quoted with ", remove quote */
 	if (*search == '\"')  {
@@ -9939,8 +10003,9 @@
 	boundary = ast_strdupa(search - 2);
 	boundary[0] = boundary[1] = '-';
 	/* Remove final quote */
-	if (boundaryisquoted)
+	if (boundaryisquoted) {
 		boundary[strlen(boundary) - 1] = '\0';
+	}
 
 	/* search for the boundary marker, the empty line delimiting headers from
 	   sdp part and the end boundry if it exists */
@@ -9954,11 +10019,12 @@
 			}
 			found_application_sdp = FALSE;
 		}
-		if (!strcasecmp(line, "Content-Type: application/sdp"))
+		if (!strcasecmp(line, "Content-Type: application/sdp")) {
 			found_application_sdp = TRUE;
+		}
 
 		if (ast_strlen_zero(line)) {
-			if (found_application_sdp && !found_end_of_headers){
+			if (found_application_sdp && !found_end_of_headers) {
 				req->sdp_start = x;
 				found_end_of_headers = TRUE;
 			}
@@ -9987,12 +10053,15 @@
 	/* Ensure hold flags are cleared so that overlapping flags do not conflict */
 	ast_clear_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD);
 
-	if (sendonly == 1)	/* One directional hold (sendonly/recvonly) */
+	if (sendonly == 1) {
+		/* One directional hold (sendonly/recvonly) */
 		ast_set_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD_ONEDIR);
-	else if (sendonly == 2)	/* Inactive stream */
+	} else if (sendonly == 2) {
+		/* Inactive stream */
 		ast_set_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD_INACTIVE);
-	else
+	} else {
 		ast_set_flag(&dialog->flags[1], SIP_PAGE2_CALL_ONHOLD_ACTIVE);
+	}
 	return;
 }
 
@@ -10147,15 +10216,15 @@
 		case 'a':
 			if (process_sdp_a_sendonly(value, &sendonly)) {
 				processed = TRUE;
-			}
-			else if (process_sdp_a_audio(value, p, &newaudiortp, &last_rtpmap_codec))
+			} else if (process_sdp_a_audio(value, p, &newaudiortp, &last_rtpmap_codec)) {
 				processed = TRUE;
-			else if (process_sdp_a_video(value, p, &newvideortp, &last_rtpmap_codec))
+			} else if (process_sdp_a_video(value, p, &newvideortp, &last_rtpmap_codec)) {
 				processed = TRUE;
-			else if (process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec))
+			} else if (process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec)) {
 				processed = TRUE;
-			else if (process_sdp_a_image(value, p))
+			} else if (process_sdp_a_image(value, p)) {
 				processed = TRUE;
+			}
 
 			if (process_sdp_a_ice(value, p, p->rtp)) {
 				processed = TRUE;
@@ -10257,8 +10326,7 @@
 						ast_log(LOG_NOTICE, "Received SAVPF profle in audio offer but AVPF is not enabled, enabling: %s\n", m);
 						secure_audio = 1;
 						ast_set_flag(&p->flags[2], SIP_PAGE3_USE_AVPF);
-					}
-					else {
+					} else {
 
 						ast_log(LOG_WARNING, "Received SAVPF profle in audio answer but AVPF is not enabled: %s\n", m);
 						continue;
@@ -10268,8 +10336,7 @@
 						ast_log(LOG_NOTICE, "Received SAVP profle in audio offer but AVPF is enabled, disabling: %s\n", m);
 						secure_audio = 1;
 						ast_clear_flag(&p->flags[2], SIP_PAGE3_USE_AVPF);
-					}
-					else {
+					} else {
 						ast_log(LOG_WARNING, "Received SAVP profile in audio offer but AVPF is enabled: %s\n", m);
 						continue;
 					}
@@ -10286,8 +10353,7 @@
 					if (req->method != SIP_RESPONSE) {
 						ast_log(LOG_NOTICE, "Received AVPF profile in audio offer but AVPF is not enabled, enabling: %s\n", m);
 						ast_set_flag(&p->flags[2], SIP_PAGE3_USE_AVPF);
-					}
-					else {
+					} else {
 						ast_log(LOG_WARNING, "Received AVP profile in audio answer but AVPF is enabled: %s\n", m);
 						continue;
 					}
@@ -10295,8 +10361,7 @@
 					if (req->method != SIP_RESPONSE) {
 						ast_log(LOG_NOTICE, "Received AVP profile in audio answer but AVPF is enabled, disabling: %s\n", m);
 						ast_clear_flag(&p->flags[2], SIP_PAGE3_USE_AVPF);
-					}
-					else {
+					} else {
 						ast_log(LOG_WARNING, "Received AVP profile in audio answer but AVPF is enabled: %s\n", m);
 						continue;
 					}
@@ -10331,9 +10396,8 @@
 				res = -1;
 				goto process_sdp_cleanup;
 			}
-		}
-		/* Check for 'video' media offer */
-		else if (strncmp(m, "video ", 6) == 0) {
+		} else if (strncmp(m, "video ", 6) == 0) {
+			/* 'video' media offer */
 			if ((sscanf(m, "video %30u/%30u %17s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
 			    (sscanf(m, "video %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
 				codecs = m + len;
@@ -10410,9 +10474,8 @@
 				res = -1;
 				goto process_sdp_cleanup;
 			}
-		}
-		/* Check for 'text' media offer */
-		else if (strncmp(m, "text ", 5) == 0) {
+		} else if (strncmp(m, "text ", 5) == 0) {
+			/* 'text' media offer */
 			if ((sscanf(m, "text %30u/%30u %17s %n", &x, &numberofports, protocol, &len) == 3 && len > 0) ||
 			    (sscanf(m, "text %30u %17s %n", &x, protocol, &len) == 2 && len > 0)) {
 				codecs = m + len;
@@ -10474,9 +10537,8 @@
 				res = -1;
 				goto process_sdp_cleanup;
 			}
-		}
-		/* Check for 'image' media offer */
-		else if (strncmp(m, "image ", 6) == 0) {
+		} else if (strncmp(m, "image ", 6) == 0) {
+			/* 'image' media offer */
 			if (((sscanf(m, "image %30u udptl t38%n", &x, &len) == 1 && len > 0) ||
 			     (sscanf(m, "image %30u UDPTL t38%n", &x, &len) == 1 && len > 0))) {
 				/* produce zero-port m-line since it may be needed later
@@ -10604,9 +10666,8 @@
 					} else if (process_sdp_a_audio(value, p, &newaudiortp, &last_rtpmap_codec)) {
 						processed = TRUE;
 					}
-				}
-				/* Video specific scanning */
-				else if (video) {
+				} else if (video) {
+					/* Video specific scanning */
 					if (process_sdp_a_ice(value, p, p->vrtp)) {
 						processed = TRUE;
 					} else if (process_sdp_a_dtls(value, p, p->vrtp)) {
@@ -10621,9 +10682,8 @@
 					} else if (process_sdp_a_video(value, p, &newvideortp, &last_rtpmap_codec)) {
 						processed = TRUE;
 					}
-				}
-				/* Text (T.140) specific scanning */
-				else if (text) {
+				} else if (text) {
+					/* Text (T.140) specific scanning */
 					if (process_sdp_a_ice(value, p, p->trtp)) {
 						processed = TRUE;
 					} else if (process_sdp_a_text(value, p, &newtextrtp, red_fmtp, &red_num_gen, red_data_pt, &last_rtpmap_codec)) {
@@ -10632,11 +10692,11 @@
 						processed_crypto = TRUE;
 						processed = TRUE;
 					}
-				}
-				/* Image (T.38 FAX) specific scanning */
-				else if (image) {
-					if (process_sdp_a_image(value, p))
+				} else if (image) {
+					/* Image (T.38 FAX) specific scanning */
+					if (process_sdp_a_image(value, p)) {
 						processed = TRUE;
+					}
 				}
 				break;
 			}
@@ -10808,8 +10868,9 @@
 				}
 			}
 		} else if (udptlportno > 0) {
-			if (debug)
+			if (debug) {
 				ast_verbose("Got T.38 Re-invite without audio. Keeping RTP active during T.38 session.\n");
+			}
 			/* Prevent audio RTCP reads */
 			if (p->owner) {
 				ast_channel_set_fd(p->owner, 1, -1);
@@ -10818,8 +10879,9 @@
 			ast_rtp_instance_set_prop(p->rtp, AST_RTP_PROPERTY_RTCP, 0);
 		} else {
 			ast_rtp_instance_stop(p->rtp);
-			if (debug)
+			if (debug) {
 				ast_verbose("Peer doesn't provide audio\n");
+			}
 		}
 	}
 
@@ -10836,8 +10898,9 @@
 			ast_rtp_codecs_payloads_copy(&newvideortp, ast_rtp_instance_get_codecs(p->vrtp), p->vrtp);
 		} else {
 			ast_rtp_instance_stop(p->vrtp);
-			if (debug)
+			if (debug) {
 				ast_verbose("Peer doesn't provide video\n");
+			}
 		}
 	}
 
@@ -10860,8 +10923,9 @@
 			ast_rtp_codecs_payloads_copy(&newtextrtp, ast_rtp_instance_get_codecs(p->trtp), p->trtp);
 		} else {
 			ast_rtp_instance_stop(p->trtp);
-			if (debug)
+			if (debug) {
 				ast_verbose("Peer doesn't provide T.140\n");
+			}
 		}
 	}
 
@@ -10876,8 +10940,9 @@
 			}
 			ast_sockaddr_set_port(isa, udptlportno);
 			ast_udptl_set_peer(p->udptl, isa);
-			if (debug)
+			if (debug) {
 				ast_debug(1, "Peer T.38 UDPTL is at port %s\n", ast_sockaddr_stringify(isa));
+			}
 
 			/* verify the far max ifp can be calculated. this requires far max datagram to be set. */
 			if (!ast_udptl_get_far_max_datagram(p->udptl)) {
@@ -10916,8 +10981,9 @@
 		} else {
 			change_t38_state(p, T38_DISABLED);
 			ast_udptl_stop(p->udptl);
-			if (debug)
+			if (debug) {
 				ast_debug(1, "Peer doesn't provide T.38 UDPTL\n");
+			}
 		}
 	}
 
@@ -10976,8 +11042,9 @@
 		if (!ast_test_flag(&p->flags[2], SIP_PAGE3_DISCARD_REMOTE_HOLD_RETRIEVAL)) {
 			ast_queue_hold(p->owner, p->mohsuggest);
 		}
-		if (sendonly)
+		if (sendonly) {
 			ast_rtp_instance_stop(p->rtp);
+		}
 		/* RTCP needs to go ahead, even if we're on hold!!! */
 		/* Activate a re-invite */
 		ast_queue_frame(p->owner, &ast_null_frame);
@@ -11110,16 +11177,19 @@
 	int found = FALSE;
 
 	if (!strcasecmp(a, "sendonly")) {
-		if (*sendonly == -1)
+		if (*sendonly == -1) {
 			*sendonly = 1;
+		}
 		found = TRUE;
 	} else if (!strcasecmp(a, "inactive")) {
-		if (*sendonly == -1)
+		if (*sendonly == -1) {
 			*sendonly = 2;
+		}
 		found = TRUE;
 	}  else if (!strcasecmp(a, "sendrecv")) {
-		if (*sendonly == -1)
+		if (*sendonly == -1) {
 			*sendonly = 0;
+		}
 		found = TRUE;
 	}
 	return found;
@@ -11263,19 +11333,22 @@
 		if (*last_rtpmap_codec < SDP_MAX_RTPMAP_CODECS) {
 			if (!(ast_rtp_codecs_payloads_set_rtpmap_type_rate(newaudiortp, NULL, codec, "audio", mimeSubtype,
 			    ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0, sample_rate))) {
-				if (debug)
+				if (debug) {
 					ast_verbose("Found audio description format %s for ID %u\n", mimeSubtype, codec);
+				}
 				//found_rtpmap_codecs[last_rtpmap_codec] = codec;
 				(*last_rtpmap_codec)++;
 				found = TRUE;
 			} else {
 				ast_rtp_codecs_payloads_unset(newaudiortp, NULL, codec);
-				if (debug)
+				if (debug) {
 					ast_verbose("Found unknown media description format %s for ID %u\n", mimeSubtype, codec);
+				}
 			}
 		} else {
-			if (debug)
+			if (debug) {
 				ast_verbose("Discarded description format %s for ID %u\n", mimeSubtype, codec);
+			}
 		}
 	} else if (sscanf(a, "fmtp: %30u %255[^\t\n]", &codec, fmtp_string) == 2) {
 		struct ast_format *format;
@@ -11345,20 +11418,23 @@
 			if (!strncasecmp(mimeSubtype, "H26", 3) || !strncasecmp(mimeSubtype, "MP4", 3)
 					|| !strncasecmp(mimeSubtype, "VP8", 3)) {
 				if (!(ast_rtp_codecs_payloads_set_rtpmap_type_rate(newvideortp, NULL, codec, "video", mimeSubtype, 0, sample_rate))) {
-					if (debug)
+					if (debug) {
 						ast_verbose("Found video description format %s for ID %u\n", mimeSubtype, codec);
+					}
 					//found_rtpmap_codecs[last_rtpmap_codec] = codec;
 					(*last_rtpmap_codec)++;
 					found = TRUE;
 				} else {
 					ast_rtp_codecs_payloads_unset(newvideortp, NULL, codec);
-					if (debug)
+					if (debug) {
 						ast_verbose("Found unknown media description format %s for ID %u\n", mimeSubtype, codec);
+					}
 				}
 			}
 		} else {
-			if (debug)
+			if (debug) {
 				ast_verbose("Discarded description format %s for ID %u\n", mimeSubtype, codec);
+			}
 		}
 	} else if (sscanf(a, "fmtp: %30u %255[^\t\n]", &codec, fmtp_string) == 2) {
 		struct ast_format *format;
@@ -11405,14 +11481,16 @@
 				if (p->trtp) {
 					ast_rtp_codecs_payloads_set_rtpmap_type_rate(newtextrtp, NULL, codec, "text", mimeSubtype, 0, sample_rate);
 					sprintf(red_fmtp, "fmtp:%u ", codec);
-					if (debug)
+					if (debug) {
 						ast_verbose("RED submimetype has payload type: %u\n", codec);
+					}
 					found = TRUE;
 				}
 			}
 		} else {
-			if (debug)
+			if (debug) {
 				ast_verbose("Discarded description format %s for ID %u\n", mimeSubtype, codec);
+			}
 		}
 	} else if (!strncmp(a, red_fmtp, strlen(red_fmtp))) {
 		/* count numbers of generations in fmtp */
@@ -11527,10 +11605,11 @@
 		found = TRUE;
 	} else if ((sscanf(attrib, "t38faxratemanagement:%255s", s) == 1)) {
 		ast_debug(3, "RateManagement: %s\n", s);
-		if (!strcasecmp(s, "localTCF"))
+		if (!strcasecmp(s, "localTCF")) {
 			p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_LOCAL_TCF;
-		else if (!strcasecmp(s, "transferredTCF"))
+		} else if (!strcasecmp(s, "transferredTCF")) {
 			p->t38.their_parms.rate_management = AST_T38_RATE_MANAGEMENT_TRANSFERRED_TCF;
+		}
 		found = TRUE;
 	} else if ((sscanf(attrib, "t38faxudpec:%255s", s) == 1)) {
 		ast_debug(3, "UDP EC: %s\n", s);
@@ -11638,8 +11717,10 @@
 {
 	const char *tmp = sip_get_header(orig, field);
 
-	if (!ast_strlen_zero(tmp)) /* Add what we're responding to */
+	if (!ast_strlen_zero(tmp)) {
+		/* Add what we're responding to */
 		return add_header(req, field, tmp);
+	}
 	ast_log(LOG_NOTICE, "No field '%s' present to copy\n", field);
 	return -1;
 }
@@ -11652,8 +11733,9 @@
 	for (;;) {
 		const char *tmp = __get_header(orig, field, &start);
 
-		if (ast_strlen_zero(tmp))
+		if (ast_strlen_zero(tmp)) {
 			break;
+		}
 		/* Add what we're responding to */
 		add_header(req, field, tmp);
 		copied++;
@@ -11678,8 +11760,9 @@
 		char new[512];
 		const char *oh = __get_header(orig, field, &start);
 
-		if (ast_strlen_zero(oh))
+		if (ast_strlen_zero(oh)) {
 			break;
+		}
 
 		if (!copied) {	/* Only check for empty rport in topmost via header */
 			char leftmost[512], *others, *rport;
@@ -11687,13 +11770,15 @@
 			/* Only work on leftmost value */
 			ast_copy_string(leftmost, oh, sizeof(leftmost));
 			others = strchr(leftmost, ',');
-			if (others)
-			    *others++ = '\0';
+			if (others) {
+				*others++ = '\0';
+			}
 
 			/* Find ;rport;  (empty request) */
 			rport = strstr(leftmost, ";rport");
-			if (rport && *(rport+6) == '=')
+			if (rport && *(rport+6) == '=') {
 				rport = NULL;		/* We already have a parameter to rport */
+			}
 
 			if (((ast_test_flag(&p->flags[0], SIP_NAT_FORCE_RPORT)) || (rport && ast_test_flag(&p->flags[0], SIP_NAT_RPORT_PRESENT)))) {
 				/* We need to add received port - rport */
@@ -11703,10 +11788,11 @@
 
 				if (rport) {
 					end = strchr(rport + 1, ';');
-					if (end)
+					if (end) {
 						memmove(rport, end, strlen(end) + 1);
-					else
+					} else {
 						*rport = '\0';
+					}
 				}
 
 				/* Add rport to first VIA header if requested */
@@ -11766,24 +11852,26 @@
 	int debug=sip_debug_test_pvt(p);
 	int tls_on = FALSE;
 
-	if (debug)
+	if (debug) {
 		ast_verbose("set_destination: Parsing <%s> for address/port to send to\n", uri);
+	}
 
 	if ((trans = strcasestr(uri, ";transport="))) {
 		trans += strlen(";transport=");
 
 		if (!strncasecmp(trans, "ws", 2)) {
-			if (debug)
+			if (debug) {
 				ast_verbose("set_destination: URI is for WebSocket, we can't set destination\n");
+			}
 			return;
 		}
 	}
 
 	/* Find and parse hostname */
 	h = strchr(uri, '@');
-	if (h)
+	if (h) {
 		++h;
-	else {
+	} else {
 		h = uri;
 		if (!strncasecmp(h, "sip:", 4)) {
 			h += 4;
@@ -11793,8 +11881,9 @@
 		}
 	}
 	hn = strcspn(h, ";>") + 1;
-	if (hn > sizeof(hostname))
+	if (hn > sizeof(hostname)) {
 		hn = sizeof(hostname);
+	}
 	ast_copy_string(hostname, h, hn);
 	/* XXX bug here if string has been trimmed to sizeof(hostname) */
 	h += hn - 1;
@@ -11814,8 +11903,9 @@
 		maddr += 6;
 		hn = strspn(maddr, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 			           "0123456789-.:[]") + 1;
-		if (hn > sizeof(hostname))
+		if (hn > sizeof(hostname)) {
 			hn = sizeof(hostname);
+		}
 		ast_copy_string(hostname, maddr, hn);
 
 		port = ast_sockaddr_port(&p->sa);
@@ -11847,10 +11937,12 @@
 	/* Initialize a response */
 	memset(resp, 0, sizeof(*resp));
 	resp->method = SIP_RESPONSE;
-	if (!(resp->data = ast_str_create(SIP_MIN_PACKET)))
+	if (!(resp->data = ast_str_create(SIP_MIN_PACKET))) {
 		goto e_return;
-	if (!(resp->content = ast_str_create(SIP_MIN_PACKET)))
+	}
+	if (!(resp->content = ast_str_create(SIP_MIN_PACKET))) {
 		goto e_free_data;
+	}
 	resp->header[0] = 0;
 	ast_str_set(&resp->data, 0, "SIP/2.0 %s\r\n", msg);
 	resp->headers++;
@@ -11868,10 +11960,12 @@
 {
 	/* Initialize a request */
 	memset(req, 0, sizeof(*req));
-	if (!(req->data = ast_str_create(SIP_MIN_PACKET)))
+	if (!(req->data = ast_str_create(SIP_MIN_PACKET))) {
 		goto e_return;
-	if (!(req->content = ast_str_create(SIP_MIN_PACKET)))
+	}
+	if (!(req->content = ast_str_create(SIP_MIN_PACKET))) {
 		goto e_free_data;
+	}
 	req->method = sipmethod;
 	req->header[0] = 0;
 	ast_str_set(&req->data, 0, "%s %s SIP/2.0\r\n", sip_methods[sipmethod].text, recip);
@@ -11922,15 +12016,17 @@
 		case SIP_UPDATE:
 		case SIP_SUBSCRIBE:
 		case SIP_NOTIFY:
-			if ((msg[0] >= '1' && msg[0] <= '3') || !strncmp(msg, "485", 3))
+			if ((msg[0] >= '1' && msg[0] <= '3') || !strncmp(msg, "485", 3)) {
 				return 1;
+			}
 			break;
 
 		/* 2xx, 3xx, 485 */
 		case SIP_REGISTER:
 		case SIP_OPTIONS:
-			if (msg[0] == '2' || msg[0] == '3' || !strncmp(msg, "485", 3))
+			if (msg[0] == '2' || msg[0] == '3' || !strncmp(msg, "485", 3)) {
 				return 1;
+			}
 			break;
 
 		/* 3xx, 485 */
@@ -11938,14 +12034,16 @@
 		case SIP_PRACK:
 		case SIP_MESSAGE:
 		case SIP_PUBLISH:
-			if (msg[0] == '3' || !strncmp(msg, "485", 3))
+			if (msg[0] == '3' || !strncmp(msg, "485", 3)) {
 				return 1;
+			}
 			break;
 
 		/* 2xx, 3xx, 4xx, 5xx, 6xx */
 		case SIP_REFER:
-			if (msg[0] >= '2' && msg[0] <= '6')
+			if (msg[0] >= '2' && msg[0] <= '6') {
 				return 1;
+			}
 			break;
 
 		/* contact will not be included for everything else */
@@ -11967,26 +12065,29 @@
 
 	init_resp(resp, msg);
 	copy_via_headers(p, resp, req, "Via");
-	if (msg[0] == '1' || msg[0] == '2')
+	if (msg[0] == '1' || msg[0] == '2') {
 		copy_all_header(resp, req, "Record-Route");
+	}
 	copy_header(resp, req, "From");
 	ot = sip_get_header(req, "To");
 	if (!strcasestr(ot, "tag=") && strncmp(msg, "100", 3)) {
 		/* Add the proper tag if we don't have it already.  If they have specified
 		   their tag, use it.  Otherwise, use our own tag */
-		if (!ast_strlen_zero(p->theirtag) && ast_test_flag(&p->flags[0], SIP_OUTGOING))

[... 3408 lines stripped ...]



More information about the asterisk-commits mailing list