[Asterisk-code-review] Remove constant conditionals (dead-code). (asterisk[13])

Corey Farrell asteriskteam at digium.com
Mon Dec 18 17:40:18 CST 2017


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/7631


Change subject: Remove constant conditionals (dead-code).
......................................................................

Remove constant conditionals (dead-code).

Some variables are set and never changed, making them constant.  This
means that code in the 'false' block of the conditional is unreachable.

In the case of chan_skinny I used preprocessor directive `#if 0` as I'm
unsure if the video handling could be enabled in the future.

Change-Id: I62e2aac353d739fb3c983cf768933120f5fba059
---
M channels/chan_skinny.c
M main/manager_system.c
M main/stdtime/localtime.c
M main/xmldoc.c
M res/res_config_ldap.c
5 files changed, 18 insertions(+), 78 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/31/7631/1

diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index ccf6a94..97634bc 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -4756,15 +4756,19 @@
 {
 	struct skinny_line *l = sub->line;
 	struct skinny_device *d = l->device;
+#if 0
 	int hasvideo = 0;
+#endif
 	struct ast_sockaddr bindaddr_tmp;
 
 	skinny_locksub(sub);
 	SKINNY_DEBUG(DEBUG_AUDIO, 3, "Sub %u - Starting RTP\n", sub->callid);
 	ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr);
 	sub->rtp = ast_rtp_instance_new("asterisk", sched, &bindaddr_tmp, NULL);
+#if 0
 	if (hasvideo)
 		sub->vrtp = ast_rtp_instance_new("asterisk", sched, &bindaddr_tmp, NULL);
+#endif
 
 	if (sub->rtp) {
 		ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_RTCP, 1);
@@ -4778,11 +4782,13 @@
 		ast_channel_set_fd(sub->owner, 0, ast_rtp_instance_fd(sub->rtp, 0));
 		ast_channel_set_fd(sub->owner, 1, ast_rtp_instance_fd(sub->rtp, 1));
 	}
+#if 0
 	if (hasvideo && sub->vrtp && sub->owner) {
 		ast_rtp_instance_set_channel_id(sub->vrtp, ast_channel_uniqueid(sub->owner));
 		ast_channel_set_fd(sub->owner, 2, ast_rtp_instance_fd(sub->vrtp, 0));
 		ast_channel_set_fd(sub->owner, 3, ast_rtp_instance_fd(sub->vrtp, 1));
 	}
+#endif
 	if (sub->rtp) {
 		ast_rtp_instance_set_qos(sub->rtp, qos.tos_audio, qos.cos_audio, "Skinny RTP");
 		ast_rtp_instance_set_prop(sub->rtp, AST_RTP_PROPERTY_NAT, l->nat);
diff --git a/main/manager_system.c b/main/manager_system.c
index b852c52..7a4896a 100644
--- a/main/manager_system.c
+++ b/main/manager_system.c
@@ -44,7 +44,6 @@
 
 int manager_system_init(void)
 {
-	int ret = 0;
 	struct stasis_topic *manager_topic;
 	struct stasis_topic *system_topic;
 	struct stasis_message_router *message_router;
@@ -68,14 +67,6 @@
 	}
 
 	ast_register_cleanup(manager_system_shutdown);
-
-	/* If somehow we failed to add any routes, just shut down the whole
-	 * thing and fail it.
-	 */
-	if (ret) {
-		manager_system_shutdown();
-		return -1;
-	}
 
 	return 0;
 }
diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c
index 5b5526e..64840e8 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -1508,16 +1508,14 @@
 			}
 		} else {
 			long	theirstdoffset;
-			long	theirdstoffset;
 			long	theiroffset;
-			int	isdst;
 			int	i;
 			int	j;
 
 			if (*name != '\0')
 				return -1;
 			/*
-			** Initial values of theirstdoffset and theirdstoffset.
+			** Initial values of theirstdoffset.
 			*/
 			theirstdoffset = 0;
 			for (i = 0; i < sp->timecnt; ++i) {
@@ -1528,19 +1526,6 @@
 					break;
 				}
 			}
-			theirdstoffset = 0;
-			for (i = 0; i < sp->timecnt; ++i) {
-				j = sp->types[i];
-				if (sp->ttis[j].tt_isdst) {
-					theirdstoffset =
-						-sp->ttis[j].tt_gmtoff;
-					break;
-				}
-			}
-			/*
-			** Initially we're assumed to be in standard time.
-			*/
-			isdst = FALSE;
 			theiroffset = theirstdoffset;
 			/*
 			** Now juggle transition times and types
@@ -1552,32 +1537,13 @@
 				if (sp->ttis[j].tt_ttisgmt) {
 					/* No adjustment to transition time */
 				} else {
-					/*
-					** If summer time is in effect, and the
-					** transition time was not specified as
-					** standard time, add the summer time
-					** offset to the transition time;
-					** otherwise, add the standard time
-					** offset to the transition time.
-					*/
-					/*
-					** Transitions from DST to DDST
-					** will effectively disappear since
-					** POSIX provides for only one DST
-					** offset.
-					*/
-					if (isdst && !sp->ttis[j].tt_ttisstd) {
-						sp->ats[i] += dstoffset -
-							theirdstoffset;
-					} else {
-						sp->ats[i] += stdoffset -
-							theirstdoffset;
-					}
+					/* Add the standard time offset to the transition time. */
+					sp->ats[i] += stdoffset - theirstdoffset;
 				}
 				theiroffset = -sp->ttis[j].tt_gmtoff;
-				if (sp->ttis[j].tt_isdst)
-					theirdstoffset = theiroffset;
-				else	theirstdoffset = theiroffset;
+				if (!sp->ttis[j].tt_isdst) {
+					theirstdoffset = theiroffset;
+				}
 			}
 			/*
 			** Finally, fill in ttis.
diff --git a/main/xmldoc.c b/main/xmldoc.c
index da753cd..5addb23 100644
--- a/main/xmldoc.c
+++ b/main/xmldoc.c
@@ -1413,7 +1413,7 @@
 static int xmldoc_parse_specialtags(struct ast_xml_node *fixnode, const char *tabs, const char *posttabs, struct ast_str **buffer)
 {
 	struct ast_xml_node *node = fixnode;
-	int ret = 0, i, count = 0;
+	int ret = 0, i;
 
 	if (!node || !ast_xml_node_get_children(node)) {
 		return ret;
@@ -1440,8 +1440,8 @@
 		/* parse <para> elements inside special tags. */
 		for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) {
 			/* first <para> just print it without tabs at the begining. */
-			if ((xmldoc_parse_para(node, (!count ? "" : tabs), posttabs, buffer) == 2)
-				|| (xmldoc_parse_info(node, (!count ? "": tabs), posttabs, buffer) == 2)) {
+			if ((xmldoc_parse_para(node, "", posttabs, buffer) == 2)
+				|| (xmldoc_parse_info(node, "", posttabs, buffer) == 2)) {
 				ret = 2;
 			}
 		}
diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index a21aa31..096e715 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -311,11 +311,8 @@
 	BerElement *ber = NULL;
 	struct ast_variable *var = NULL;
 	struct ast_variable *prev = NULL;
-	int is_delimited = 0;
-	int i = 0;
 	char *ldap_attribute_name;
 	struct berval *value;
-	int pos = 0;
 
 	ldap_attribute_name = ldap_first_attribute(ldapConn, ldap_entry, &ber);
 
@@ -340,34 +337,14 @@
 					ast_debug(2, "md5: %s\n", valptr);
 				}
 				if (valptr) {
-					/* ok, so looping through all delimited values except the last one (not, last character is not delimited...) */
-					if (is_delimited) {
-						i = 0;
-						pos = 0;
-						while (!ast_strlen_zero(valptr + i)) {
-							if (valptr[i] == ';') {
-								valptr[i] = '\0';
-								if (prev) {
-									prev->next = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name);
-									if (prev->next) {
-										prev = prev->next;
-									}
-								} else {
-									prev = var = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name);
-								}
-								pos = i + 1;
-							}
-							i++;
-						}
-					}
-					/* for the last delimited value or if the value is not delimited: */
+					/* add the value to the list */
 					if (prev) {
-						prev->next = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name);
+						prev->next = ast_variable_new(attribute_name, valptr, table_config->table_name);
 						if (prev->next) {
 							prev = prev->next;
 						}
 					} else {
-						prev = var = ast_variable_new(attribute_name, &valptr[pos], table_config->table_name);
+						prev = var = ast_variable_new(attribute_name, valptr, table_config->table_name);
 					}
 				}
 			}

-- 
To view, visit https://gerrit.asterisk.org/7631
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I62e2aac353d739fb3c983cf768933120f5fba059
Gerrit-Change-Number: 7631
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171218/e55bf99c/attachment.html>


More information about the asterisk-code-review mailing list