From 56b6e954cfa0173083770be2e9248c25aa10303b Mon Sep 17 00:00:00 2001
From: Andrey Volk <andywolk@gmail.com>
Date: Tue, 11 Jan 2022 19:16:53 +0300
Subject: [PATCH] [Core] Fix dead nested assignments

---
 src/switch.c                    |  8 ++++----
 src/switch_core.c               |  4 ++--
 src/switch_core_file.c          |  4 ++--
 src/switch_core_media.c         | 10 ++--------
 src/switch_core_media_bug.c     |  8 +++-----
 src/switch_core_session.c       | 20 +++++++-------------
 src/switch_core_sqldb.c         | 12 +++++-------
 src/switch_core_state_machine.c |  2 +-
 src/switch_event.c              |  4 +---
 src/switch_ivr.c                |  3 +--
 src/switch_ivr_async.c          | 10 ++++------
 src/switch_ivr_bridge.c         |  6 ++----
 src/switch_ivr_originate.c      |  4 ++--
 src/switch_ivr_play_say.c       |  2 +-
 src/switch_loadable_module.c    |  4 +---
 src/switch_msrp.c               |  3 +--
 src/switch_rtp.c                |  8 ++++----
 src/switch_stun.c               |  3 +--
 src/switch_time.c               |  4 ++--
 src/switch_utils.c              |  5 ++---
 src/switch_xml.c                |  2 +-
 21 files changed, 49 insertions(+), 77 deletions(-)

diff --git a/src/switch.c b/src/switch.c
index 2f5274099e..3ace9fb7cf 100644
--- a/src/switch.c
+++ b/src/switch.c
@@ -230,7 +230,7 @@ void WINAPI service_main(DWORD numArgs, char **args)
 static int check_fd(int fd, int ms)
 {
 	struct pollfd pfds[2] = { { 0 } };
-	int s, r = 0, i = 0;
+	int s, r = 0;
 
 	pfds[0].fd = fd;
 	pfds[0].events = POLLIN | POLLERR;
@@ -242,7 +242,7 @@ static int check_fd(int fd, int ms)
 		r = -1;
 
 		if ((pfds[0].revents & POLLIN)) {
-			if ((i = read(fd, &r, sizeof(r))) > -1) {
+			if (read(fd, &r, sizeof(r)) > -1) {
 				(void)write(fd, &r, sizeof(r));
 			}
 		}
@@ -1206,9 +1206,9 @@ int main(int argc, char *argv[])
 #ifndef WIN32
 	if (do_wait) {
 		if (fds[1] > -1) {
-			int i, v = 1;
+			int v = 1;
 
-			if ((i = write(fds[1], &v, sizeof(v))) < 0) {
+			if (write(fds[1], &v, sizeof(v)) < 0) {
 				fprintf(stderr, "System Error [%s]\n", strerror(errno));
 			} else {
 				(void)read(fds[1], &v, sizeof(v));
diff --git a/src/switch_core.c b/src/switch_core.c
index 48903eee95..d1bba3fa3e 100644
--- a/src/switch_core.c
+++ b/src/switch_core.c
@@ -3425,7 +3425,7 @@ SWITCH_DECLARE(int) switch_stream_spawn(const char *cmd, switch_bool_t shell, sw
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "posix_spawn is unsupported on current platform\n");
 	return 1;
 #else
-	int status = 0, rval;
+	int status = 0;
 	char buffer[1024];
 	pid_t pid;
 	char *pdata = NULL, *argv[64];
@@ -3521,7 +3521,7 @@ SWITCH_DECLARE(int) switch_stream_spawn(const char *cmd, switch_bool_t shell, sw
 					.revents = 0
 			};
 
-			while ((rval = poll(pfds, 2, /*timeout*/-1)) > 0) {
+			while (poll(pfds, 2, /*timeout*/-1) > 0) {
 				if (pfds[0].revents & POLLIN) {
 					int bytes_read = read(cout_pipe[0], buffer, sizeof(buffer));
 					stream->raw_write_function(stream, (unsigned char *)buffer, bytes_read);
diff --git a/src/switch_core_file.c b/src/switch_core_file.c
index bc99a451ef..84e6acb3c0 100644
--- a/src/switch_core_file.c
+++ b/src/switch_core_file.c
@@ -949,10 +949,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_pre_close(switch_file_handle_t
 
 	if (fh->pre_buffer) {
 		if (switch_test_flag(fh, SWITCH_FILE_FLAG_WRITE)) {
-			switch_size_t rlen, blen;
+			switch_size_t blen;
 			int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
 
-			while ((rlen = switch_buffer_inuse(fh->pre_buffer))) {
+			while (switch_buffer_inuse(fh->pre_buffer)) {
 				if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
 					if (!asis)
 						blen /= 2;
diff --git a/src/switch_core_media.c b/src/switch_core_media.c
index 347735cf1b..d1397a833e 100644
--- a/src/switch_core_media.c
+++ b/src/switch_core_media.c
@@ -6667,7 +6667,6 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
 
 		if (switch_channel_test_flag(session->channel, CF_PROTO_HOLD)) {
 			int media_on_hold_a = switch_true(switch_channel_get_variable_dup(session->channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1));
-			int media_on_hold_b = 0;
 			int bypass_after_hold_a = 0;
 			int bypass_after_hold_b = 0;
 
@@ -6676,7 +6675,7 @@ SWITCH_DECLARE(int) switch_core_media_toggle_hold(switch_core_session_t *session
 			}
 
 			if (b_channel) {
-				if ((media_on_hold_b = switch_true(switch_channel_get_variable_dup(b_channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1)))) {
+				if (switch_true(switch_channel_get_variable_dup(b_channel, "bypass_media_resume_on_hold", SWITCH_FALSE, -1))) {
 					bypass_after_hold_b = switch_true(switch_channel_get_variable_dup(b_channel, "bypass_media_after_hold", SWITCH_FALSE, -1));
 				}
 			}
@@ -13622,16 +13621,12 @@ SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_
 SWITCH_DECLARE(void) switch_core_media_merge_sdp_codec_string(switch_core_session_t *session, const char *r_sdp,
 															  switch_sdp_type_t sdp_type, const char *codec_string)
 {
-
-	
-
 	sdp_parser_t *parser;
 	sdp_session_t *sdp;
-	switch_media_handle_t *smh;
 
 	switch_assert(session);
 
-	if (!(smh = session->media_handle)) {
+	if (!session->media_handle) {
 		return;
 	}
 
@@ -13652,7 +13647,6 @@ SWITCH_DECLARE(void) switch_core_media_merge_sdp_codec_string(switch_core_sessio
 
 		sdp_parser_free(parser);
 	}
-
 }
 
 
diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c
index eca4c495d2..7aabceb7b7 100644
--- a/src/switch_core_media_bug.c
+++ b/src/switch_core_media_bug.c
@@ -466,7 +466,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_patch_spy_frame(switch_med
 {
 	switch_queue_t *spy_q = NULL;
 	int w = 0, h = 0;
-	switch_status_t status;
 	void *pop;
 	int i;
 
@@ -479,7 +478,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_patch_spy_frame(switch_med
 	spy_q = bug->spy_video_queue[rw];
 
 	while(switch_queue_size(spy_q) > 0) {
-		if ((status = switch_queue_trypop(spy_q, &pop)) == SWITCH_STATUS_SUCCESS) {
+		if (switch_queue_trypop(spy_q, &pop) == SWITCH_STATUS_SUCCESS) {
 			switch_img_free(&bug->spy_img[rw]);
 			if (!(bug->spy_img[rw] = (switch_image_t *) pop)) {
 				break;
@@ -641,7 +640,6 @@ static void *SWITCH_THREAD_FUNC video_bug_thread(switch_thread_t *thread, void *
 	switch_core_timer_init(&timer, "soft", fps_data.ms, fps_data.samples, NULL);
 
 	while (bug->ready) {
-		switch_status_t status;
 		int w = 0, h = 0, ok = 1, new_main = 0, new_other = 0, new_canvas = 0;
 		
 		switch_core_timer_next(&timer);
@@ -657,7 +655,7 @@ static void *SWITCH_THREAD_FUNC video_bug_thread(switch_thread_t *thread, void *
 		w = vw / 2;
 		h = vh;
 
-		if ((status = switch_queue_trypop(main_q, &pop)) == SWITCH_STATUS_SUCCESS) {
+		if (switch_queue_trypop(main_q, &pop) == SWITCH_STATUS_SUCCESS) {
 			switch_img_free(&img);
 
 			if (!pop) {
@@ -678,7 +676,7 @@ static void *SWITCH_THREAD_FUNC video_bug_thread(switch_thread_t *thread, void *
 		if (other_q) {
 			flush_video_queue(other_q, 1);
 
-			if ((status = switch_queue_trypop(other_q, &other_pop)) == SWITCH_STATUS_SUCCESS) {
+			if (switch_queue_trypop(other_q, &other_pop) == SWITCH_STATUS_SUCCESS) {
 				switch_img_free(&other_img);
 				other_img = (switch_image_t *) other_pop;
 
diff --git a/src/switch_core_session.c b/src/switch_core_session.c
index 32139ac98a..a590f7467c 100644
--- a/src/switch_core_session.c
+++ b/src/switch_core_session.c
@@ -526,7 +526,6 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
 																		 switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
 {
 	switch_io_event_hook_outgoing_channel_t *ptr;
-	switch_status_t status = SWITCH_STATUS_FALSE;
 	switch_endpoint_interface_t *endpoint_interface;
 	switch_channel_t *channel = NULL;
 	switch_caller_profile_t *outgoing_profile = caller_profile;
@@ -608,7 +607,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(switch_
 
 	if (session) {
 		for (ptr = session->event_hooks.outgoing_channel; ptr; ptr = ptr->next) {
-			if ((status = ptr->outgoing_channel(session, var_event, caller_profile, *new_session, flags)) != SWITCH_STATUS_SUCCESS) {
+			if (ptr->outgoing_channel(session, var_event, caller_profile, *new_session, flags) != SWITCH_STATUS_SUCCESS) {
 				break;
 			}
 		}
@@ -1116,15 +1115,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(switch_core_session_t *session)
 {
-	switch_status_t status = SWITCH_STATUS_FALSE;
 	void *pop;
 	switch_core_session_message_t *message;
 
 	switch_assert(session != NULL);
 
-
 	if (session->message_queue) {
-		while ((status = (switch_status_t) switch_queue_trypop(session->message_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+		while (switch_queue_trypop(session->message_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 			message = (switch_core_session_message_t *) pop;
 			switch_ivr_process_indications(session, message);
 			switch_core_session_free_message(&message);
@@ -1353,19 +1350,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_private_event(switch
 
 SWITCH_DECLARE(uint32_t) switch_core_session_flush_private_events(switch_core_session_t *session)
 {
-	switch_status_t status = SWITCH_STATUS_FALSE;
 	int x = 0;
 	void *pop;
 
 	if (session->private_event_queue) {
-		while ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue_pri, &pop)) == SWITCH_STATUS_SUCCESS) {
+		while (switch_queue_trypop(session->private_event_queue_pri, &pop) == SWITCH_STATUS_SUCCESS) {
 			if (pop) {
 				switch_event_t *event = (switch_event_t *) pop;
 				switch_event_destroy(&event);
 			}
 			x++;
 		}
-		while ((status = (switch_status_t) switch_queue_trypop(session->private_event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+		while (switch_queue_trypop(session->private_event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 			if (pop) {
 				switch_event_t *event = (switch_event_t *) pop;
 				switch_event_destroy(&event);
@@ -1398,7 +1394,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_try_reset(switch_core_sessio
 SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, switch_bool_t flush_dtmf, switch_bool_t reset_read_codec)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	switch_size_t has;
 
 	if (reset_read_codec) {
 		switch_core_session_set_read_codec(session, NULL);
@@ -1425,7 +1420,7 @@ SWITCH_DECLARE(void) switch_core_session_reset(switch_core_session_t *session, s
 	switch_mutex_unlock(session->codec_read_mutex);
 
 	if (flush_dtmf) {
-		while ((has = switch_channel_has_dtmf(channel))) {
+		while (switch_channel_has_dtmf(channel)) {
 			switch_channel_flush_dtmf(channel);
 		}
 	}
@@ -1496,7 +1491,7 @@ SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session
 
 	if (status == SWITCH_STATUS_SUCCESS) {
 		for (ptr = session->event_hooks.state_change; ptr; ptr = ptr->next) {
-			if ((status = ptr->state_change(session)) != SWITCH_STATUS_SUCCESS) {
+			if (ptr->state_change(session) != SWITCH_STATUS_SUCCESS) {
 				break;
 			}
 		}
@@ -1608,9 +1603,8 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t *
 	}
 
 	if ((*session)->event_queue) {
-		switch_status_t status;
 		void *pop;
-		while ((status = (switch_status_t) switch_queue_trypop((*session)->event_queue, &pop)) == SWITCH_STATUS_SUCCESS) {
+		while (switch_queue_trypop((*session)->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 			if (pop) {
 				switch_event_t *event = (switch_event_t *) pop;
 				switch_event_destroy(&event);
diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c
index 0f6ecd5841..702ee6a79c 100644
--- a/src/switch_core_sqldb.c
+++ b/src/switch_core_sqldb.c
@@ -744,7 +744,6 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
 	char *p, *s, *e;
-	switch_size_t chunk_count;
 	switch_size_t len;
 
 	switch_assert(chunk_size);
@@ -758,7 +757,7 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl
 		return switch_cache_db_execute_sql_real(dbh, sql, err);
 	}
 
-	if (!(chunk_count = strlen(sql) / chunk_size)) {
+	if (!(strlen(sql) / chunk_size)) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -878,14 +877,13 @@ SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t
 				goto end;
 			} else {
 				int running = 1;
-				int colcount;
 
 				while (running < 5000) {
 					int result = switch_core_db_step(stmt);
 					const unsigned char *txt;
 
 					if (result == SWITCH_CORE_DB_ROW) {
-						if ((colcount = switch_core_db_column_count(stmt)) > 0) {
+						if (switch_core_db_column_count(stmt) > 0) {
 							if ((txt = switch_core_db_column_text(stmt, 0))) {
 								switch_copy_string(str, (char *) txt, len);
 								status = SWITCH_STATUS_SUCCESS;
@@ -2244,7 +2242,7 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread,
 	qm->thread_running = 1;
 
 	while (qm->thread_running == 1) {
-		uint32_t i, lc;
+		uint32_t i;
 		uint32_t written = 0, iterations = 0;
 
 		if (qm->paused) {
@@ -2286,7 +2284,7 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread,
 
 	check:
 
-		if ((lc = qm_ttl(qm)) == 0) {
+		if (qm_ttl(qm) == 0) {
 			switch_mutex_lock(qm->cond2_mutex);
 			if (qm->skip_wait > 0) {
 				qm->skip_wait--;
@@ -2299,7 +2297,7 @@ static void *SWITCH_THREAD_FUNC switch_user_sql_thread(switch_thread_t *thread,
 
 		i = 40;
 
-		while (--i > 0 && (lc = qm_ttl(qm)) < 500) {
+		while (--i > 0 && qm_ttl(qm) < 500) {
 			switch_yield(5000);
 		}
 
diff --git a/src/switch_core_state_machine.c b/src/switch_core_state_machine.c
index ce47a6cd68..b2bc14a1df 100644
--- a/src/switch_core_state_machine.c
+++ b/src/switch_core_state_machine.c
@@ -589,7 +589,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
 
 			if (rstatus == SWITCH_STATUS_SUCCESS) {
 				for (ptr = session->event_hooks.state_run; ptr; ptr = ptr->next) {
-					if ((rstatus = ptr->state_run(session)) != SWITCH_STATUS_SUCCESS) {
+					if (ptr->state_run(session) != SWITCH_STATUS_SUCCESS) {
 						break;
 					}
 				}
diff --git a/src/switch_event.c b/src/switch_event.c
index a24bee0126..4cc60fa60c 100644
--- a/src/switch_event.c
+++ b/src/switch_event.c
@@ -1723,10 +1723,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
 			int x = 0;
 			for (x = 0; x < var_count; x++) {
 				char *inner_var_array[2] = { 0 };
-				int inner_var_count;
 
-				if ((inner_var_count = switch_separate_string(var_array[x], '=',
-															  inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
+				if (switch_separate_string(var_array[x], '=', inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0]))) == 2) {
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Parsing variable [%s]=[%s]\n", inner_var_array[0], inner_var_array[1]);
 					switch_event_add_header_string(e, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]);
 				}
diff --git a/src/switch_ivr.c b/src/switch_ivr.c
index ddd3a8e529..77d957fb7c 100644
--- a/src/switch_ivr.c
+++ b/src/switch_ivr.c
@@ -2135,10 +2135,9 @@ SWITCH_DECLARE(void) switch_ivr_bg_media(const char *uuid, switch_media_flag_t f
 SWITCH_DECLARE(void) switch_ivr_check_hold(switch_core_session_t *session)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	switch_media_flow_t flow;
 
 	if (switch_channel_test_flag(channel, CF_ANSWERED) && switch_channel_test_cap(channel, CC_MUTE_VIA_MEDIA_STREAM) &&
-		(flow = switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_AUDIO)) != SWITCH_MEDIA_FLOW_SENDRECV) {
+		switch_core_session_media_flow(session, SWITCH_MEDIA_TYPE_AUDIO) != SWITCH_MEDIA_FLOW_SENDRECV) {
 		switch_core_session_message_t msg = { 0 };
 
 		msg.message_id = SWITCH_MESSAGE_INDICATE_MEDIA_RENEG;
diff --git a/src/switch_ivr_async.c b/src/switch_ivr_async.c
index 707f8672dd..6dfdcf7248 100644
--- a/src/switch_ivr_async.c
+++ b/src/switch_ivr_async.c
@@ -1020,7 +1020,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_displace_session(switch_core_session_
 		return SWITCH_STATUS_FALSE;
 	}
 
-	if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
+	if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -2944,7 +2944,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_session_event(switch_core_sess
 		hangup_on_error = switch_true(p);
 	}
 
-	if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
+	if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
 		return SWITCH_STATUS_FALSE;
 	}
 
@@ -3803,7 +3803,6 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
 	switch_inband_dtmf_t *pvt = (switch_inband_dtmf_t *) user_data;
 	switch_frame_t *frame = NULL;
 	switch_channel_t *channel = switch_core_session_get_channel(pvt->session);
-	teletone_hit_type_t hit;
 
 	switch (type) {
 	case SWITCH_ABC_TYPE_INIT:
@@ -3812,7 +3811,7 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
 		break;
 	case SWITCH_ABC_TYPE_READ_REPLACE:
 		if ((frame = switch_core_media_bug_get_read_replace_frame(bug))) {
-			if ((hit = teletone_dtmf_detect(&pvt->dtmf_detect, frame->data, frame->samples)) == TT_HIT_END) {
+			if (teletone_dtmf_detect(&pvt->dtmf_detect, frame->data, frame->samples) == TT_HIT_END) {
 				switch_dtmf_t dtmf = {0};
 
 				teletone_dtmf_get(&pvt->dtmf_detect, &dtmf.digit, &dtmf.duration);
@@ -5457,7 +5456,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
 														 const char *grammar, const char *name, const char *dest, switch_asr_handle_t *ah)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
-	switch_status_t status;
 	struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
 	const char *p;
 	int resume = 0;
@@ -5465,7 +5463,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_detect_speech(switch_core_session_t *
 
 	if (!sth) {
 		/* No speech thread handle available yet, init speech detection first. */
-		if ((status = switch_ivr_detect_speech_init(session, mod_name, dest, ah)) != SWITCH_STATUS_SUCCESS) {
+		if (switch_ivr_detect_speech_init(session, mod_name, dest, ah) != SWITCH_STATUS_SUCCESS) {
 			return SWITCH_STATUS_NOT_INITALIZED;
 		}
 
diff --git a/src/switch_ivr_bridge.c b/src/switch_ivr_bridge.c
index 3e5e2145be..f91fc2c69f 100644
--- a/src/switch_ivr_bridge.c
+++ b/src/switch_ivr_bridge.c
@@ -507,7 +507,6 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 
 
 	for (;;) {
-		switch_channel_state_t b_state;
 		switch_status_t status;
 		switch_event_t *event;
 
@@ -543,7 +542,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 			goto end_of_bridge_loop;
 		}
 
-		if ((b_state = switch_channel_down_nosig(chan_b))) {
+		if (switch_channel_down_nosig(chan_b)) {
 			goto end_of_bridge_loop;
 		}
 
@@ -953,14 +952,13 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 
 static void transfer_after_bridge(switch_core_session_t *session, const char *where)
 {
-	int argc;
 	char *argv[4] = { 0 };
 	char *mydata;
 
 	switch_channel_set_variable(switch_core_session_get_channel(session), SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE, NULL);
 
 	if (!zstr(where) && (mydata = switch_core_session_strdup(session, where))) {
-		if ((argc = switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
+		if (switch_separate_string(mydata, ':', argv, (sizeof(argv) / sizeof(argv[0]))) >= 1) {
 			switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
 		} else {
 			switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No extension specified.\n");
diff --git a/src/switch_ivr_originate.c b/src/switch_ivr_originate.c
index 627f43ead6..c4f4bfa2b2 100644
--- a/src/switch_ivr_originate.c
+++ b/src/switch_ivr_originate.c
@@ -2532,12 +2532,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
 		oglobals.ignore_ring_ready = 1;
 	}
 
-	if ((var_val = switch_event_get_header(var_event, "monitor_early_media_ring"))) {
+	if ((var_val = switch_event_get_header(var_event, "monitor_early_media_ring")) && switch_true(var_val)) {
 		oglobals.early_ok = 0;
 		oglobals.monitor_early_media_ring = 1;
 	}
 
-	if ((var_val = switch_event_get_header(var_event, "monitor_early_media_fail"))) {
+	if ((var_val = switch_event_get_header(var_event, "monitor_early_media_fail")) && switch_true(var_val)) {
 		oglobals.early_ok = 0;
 		oglobals.monitor_early_media_fail = 1;
 	}
diff --git a/src/switch_ivr_play_say.c b/src/switch_ivr_play_say.c
index 1cd4c623df..25486eee7f 100644
--- a/src/switch_ivr_play_say.c
+++ b/src/switch_ivr_play_say.c
@@ -1375,7 +1375,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
 
 		status = SWITCH_STATUS_SUCCESS;
 
-		if ((alt = strchr(file, ':'))) {
+		if (strchr(file, ':')) {
 			char *dup;
 
 			if (!strncasecmp(file, "phrase:", 7)) {
diff --git a/src/switch_loadable_module.c b/src/switch_loadable_module.c
index 5442cca03a..439b8d0c19 100644
--- a/src/switch_loadable_module.c
+++ b/src/switch_loadable_module.c
@@ -3191,12 +3191,11 @@ SWITCH_DECLARE(switch_status_t) switch_say_file_handle_create(switch_say_file_ha
 SWITCH_DECLARE(void) switch_say_file(switch_say_file_handle_t *sh, const char *fmt, ...)
 {
 	char buf[256] = "";
-	int ret;
 	va_list ap;
 
 	va_start(ap, fmt);
 
-	if ((ret = switch_vsnprintf(buf, sizeof(buf), fmt, ap)) > 0) {
+	if (switch_vsnprintf(buf, sizeof(buf), fmt, ap) > 0) {
 		if (!sh->cnt++) {
 			sh->stream.write_function(&sh->stream, "file_string://%s.%s", buf, sh->ext);
 		} else if (strstr(buf, "://")) {
@@ -3204,7 +3203,6 @@ SWITCH_DECLARE(void) switch_say_file(switch_say_file_handle_t *sh, const char *f
 		} else {
 			sh->stream.write_function(&sh->stream, "!%s.%s", buf, sh->ext);
 		}
-
 	}
 
 	va_end(ap);
diff --git a/src/switch_msrp.c b/src/switch_msrp.c
index b76a043261..1f5db7ac20 100644
--- a/src/switch_msrp.c
+++ b/src/switch_msrp.c
@@ -1425,7 +1425,6 @@ end:
 static void *SWITCH_THREAD_FUNC msrp_listener(switch_thread_t *thread, void *obj)
 {
 	switch_msrp_socket_t *msock = (switch_msrp_socket_t *)obj;
-	switch_status_t rv;
 	switch_memory_pool_t *pool = NULL;
 	switch_threadattr_t *thd_attr = NULL;
 	switch_socket_t *sock = NULL;
@@ -1440,7 +1439,7 @@ static void *SWITCH_THREAD_FUNC msrp_listener(switch_thread_t *thread, void *obj
 	switch_socket_opt_set(msock->sock, SWITCH_SO_TCP_NODELAY, TRUE);
 	// switch_socket_opt_set(msock->sock, SWITCH_SO_NONBLOCK, TRUE);
 
-	while (globals.running && (rv = switch_socket_accept(&sock, msock->sock, pool)) == SWITCH_STATUS_SUCCESS) {
+	while (globals.running && switch_socket_accept(&sock, msock->sock, pool) == SWITCH_STATUS_SUCCESS) {
 		switch_memory_pool_t *worker_pool;
 		worker_helper_t *helper;
 
diff --git a/src/switch_rtp.c b/src/switch_rtp.c
index 5f4ce0f738..f0be8db97b 100644
--- a/src/switch_rtp.c
+++ b/src/switch_rtp.c
@@ -8780,8 +8780,8 @@ static int rtp_common_write(switch_rtp_t *rtp_session,
 				switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET);
 				srtp_dealloc(rtp_session->send_ctx[rtp_session->srtp_idx_rtp]);
 				rtp_session->send_ctx[rtp_session->srtp_idx_rtp] = NULL;
-				if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
-										&rtp_session->send_policy[rtp_session->srtp_idx_rtp])) || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
+				if (srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
+										&rtp_session->send_policy[rtp_session->srtp_idx_rtp]) || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
 					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR,
 									  "Error! RE-Activating %s Secure RTP SEND\n", rtp_type(rtp_session));
 					rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND] = 0;
@@ -9376,8 +9376,8 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_write_raw(switch_rtp_t *rtp_session,
 				switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_SECURE_SEND_RESET);
 				srtp_dealloc(rtp_session->send_ctx[rtp_session->srtp_idx_rtp]);
 				rtp_session->send_ctx[rtp_session->srtp_idx_rtp] = NULL;
-				if ((stat = srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
-										&rtp_session->send_policy[rtp_session->srtp_idx_rtp])) || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
+				if (srtp_create(&rtp_session->send_ctx[rtp_session->srtp_idx_rtp],
+										&rtp_session->send_policy[rtp_session->srtp_idx_rtp]) || !rtp_session->send_ctx[rtp_session->srtp_idx_rtp]) {
 					switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_ERROR, "Error! RE-Activating Secure RTP SEND\n");
 					rtp_session->flags[SWITCH_RTP_FLAG_SECURE_SEND] = 0;
 					status = SWITCH_STATUS_FALSE;
diff --git a/src/switch_stun.c b/src/switch_stun.c
index 6149ac3dc3..b0ff45b3dc 100644
--- a/src/switch_stun.c
+++ b/src/switch_stun.c
@@ -717,7 +717,6 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
 	char rip[50] = { 0 };
 	uint16_t rport = 0;
 	switch_time_t started = 0;
-	unsigned int elapsed = 0;
 	int funny = 0;
 	int size = sizeof(buf);
 	int xlen = sizeof(switch_stun_packet_header_t);
@@ -787,7 +786,7 @@ SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
 			break;
 		}
 
-		if ((elapsed = (unsigned int) ((switch_micro_time_now() - started) / 1000)) > 5000) {
+		if (((unsigned int)((switch_micro_time_now() - started) / 1000)) > 5000) {
 			*err = "Timeout";
 			switch_socket_shutdown(sock, SWITCH_SHUTDOWN_READWRITE);
 			switch_socket_close(sock);
diff --git a/src/switch_time.c b/src/switch_time.c
index 182d9ad6bd..39ad4bb597 100644
--- a/src/switch_time.c
+++ b/src/switch_time.c
@@ -413,7 +413,7 @@ typedef struct interval_timer interval_timer_t;
 static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval)
 {
 	struct itimerspec val;
-	int fd, r;
+	int fd;
 	uint64_t exp;
 
 	fd = timerfd_create(CLOCK_MONOTONIC, 0);
@@ -432,7 +432,7 @@ static switch_status_t timerfd_start_interval(interval_timer_t *it, int interval
 		return SWITCH_STATUS_GENERR;
 	}
 
-	if ((r = read(fd, &exp, sizeof(exp))) < 0) {
+	if (read(fd, &exp, sizeof(exp)) < 0) {
 		close(fd);
 		return SWITCH_STATUS_GENERR;
 	}
diff --git a/src/switch_utils.c b/src/switch_utils.c
index 1a93411489..d8b830943a 100644
--- a/src/switch_utils.c
+++ b/src/switch_utils.c
@@ -1142,7 +1142,7 @@ SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to,
 	}
 
 	if (!zstr(file) && !zstr(convert_cmd) && !zstr(convert_ext)) {
-		if ((ext = strrchr(file, '.'))) {
+		if (strrchr(file, '.')) {
 			dupfile = strdup(file);
 			if ((ext = strrchr(dupfile, '.'))) {
 				*ext++ = '\0';
@@ -1820,9 +1820,8 @@ SWITCH_DECLARE(switch_status_t) switch_resolve_host(const char *host, char *buf,
 {
 
 	struct addrinfo *ai;
-	int err;
 
-	if ((err = getaddrinfo(host, 0, 0, &ai))) {
+	if (getaddrinfo(host, 0, 0, &ai)) {
 		return SWITCH_STATUS_FALSE;
 	}
 
diff --git a/src/switch_xml.c b/src/switch_xml.c
index 6467758b72..1a3ecef9b6 100644
--- a/src/switch_xml.c
+++ b/src/switch_xml.c
@@ -1257,7 +1257,7 @@ static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_
 	char *wp = ebuf;
 	char *ep = ebuf + elen - 1;
 
-	if (!(var = strstr(rp, "$${"))) {
+	if (!strstr(rp, "$${")) {
 		*newlen = strlen(buf);
 		return buf;
 	}