[prev in list] [next in list] [prev in thread] [next in thread] 

List:       asterisk-commits
Subject:    [asterisk-commits] =?utf-8?q?Remove_constant_conditionals_=28dead?= =?utf-8?b?LWNvZGUpLiAoYXN0ZXJpc2
From:       SVN commits to the Asterisk project <asterisk-commits () lists ! digium ! com>
Date:       2017-12-20 1:17:25
Message-ID: mailman.3941.1513732689.1215.asterisk-commits () lists ! digium ! com
[Download RAW message or body]

Jenkins2 has submitted this change and it was merged. ( \
https://gerrit.asterisk.org/7629 )

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 chan_skinny and res_config_ldap I used preprocessor directive `#if 0`
as I'm unsure if the unreachable code 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, 19 insertions(+), 52 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index 6f4231a..0093a1f 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -4753,15 +4753,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);
@@ -4775,11 +4779,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 b20deea..8ef15e3 100644
--- a/main/manager_system.c
+++ b/main/manager_system.c
@@ -42,7 +42,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;
@@ -66,14 +65,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 88b8020..eac199a 100644
--- a/main/stdtime/localtime.c
+++ b/main/stdtime/localtime.c
@@ -1506,16 +1506,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) {
@@ -1526,19 +1524,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
@@ -1550,32 +1535,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 e9a0afc..105bee0 100644
--- a/main/xmldoc.c
+++ b/main/xmldoc.c
@@ -1411,7 +1411,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;
@@ -1438,8 +1438,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 8f24a8d..6d4b76d 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -309,8 +309,10 @@
 	BerElement *ber = NULL;
 	struct ast_variable *var = NULL;
 	struct ast_variable *prev = NULL;
+#if 0
 	int is_delimited = 0;
 	int i = 0;
+#endif
 	char *ldap_attribute_name;
 	struct berval *value;
 	int pos = 0;
@@ -338,6 +340,7 @@
 					ast_debug(2, "md5: %s\n", valptr);
 				}
 				if (valptr) {
+#if 0
 					/* ok, so looping through all delimited values except the last one (not, last \
character is not delimited...) */  if (is_delimited) {
 						i = 0;
@@ -358,6 +361,7 @@
 							i++;
 						}
 					}
+#endif
 					/* for the last delimited value or if the value is not delimited: */
 					if (prev) {
 						prev->next = ast_variable_new(attribute_name, &valptr[pos], \
table_config->table_name);

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

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I62e2aac353d739fb3c983cf768933120f5fba059
Gerrit-Change-Number: 7629
Gerrit-PatchSet: 4
Gerrit-Owner: Corey Farrell <git@cfware.com>
Gerrit-Reviewer: Corey Farrell <git@cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett@digium.com>


[Attachment #3 (text/html)]

<p>Jenkins2 <strong>merged</strong> this change.</p><p><a \
href="https://gerrit.asterisk.org/7629">View Change</a></p><div \
style="white-space:pre-wrap">Approvals:  Richard Mudgett: Looks good to me, but \
someone else must approve  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Remove \
constant conditionals (dead-code).<br><br>Some variables are set and never changed, \
making them constant.  This<br>means that code in the &#39;false&#39; block of the \
conditional is unreachable.<br><br>In chan_skinny and res_config_ldap I used \
preprocessor directive `#if 0`<br>as I&#39;m unsure if the unreachable code could be \
enabled in the future.<br><br>Change-Id: \
I62e2aac353d739fb3c983cf768933120f5fba059<br>---<br>M channels/chan_skinny.c<br>M \
main/manager_system.c<br>M main/stdtime/localtime.c<br>M main/xmldoc.c<br>M \
res/res_config_ldap.c<br>5 files changed, 19 insertions(+), 52 \
deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: \
pre-wrap;">diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c<br>index \
6f4231a..0093a1f 100644<br>--- a/channels/chan_skinny.c<br>+++ \
b/channels/chan_skinny.c<br>@@ -4753,15 +4753,19 @@<br> {<br> 	struct skinny_line *l \
= sub-&gt;line;<br> 	struct skinny_device *d = l-&gt;device;<br>+#if 0<br> 	int \
hasvideo = 0;<br>+#endif<br> 	struct ast_sockaddr bindaddr_tmp;<br> <br> \
skinny_locksub(sub);<br> 	SKINNY_DEBUG(DEBUG_AUDIO, 3, &quot;Sub %u - Starting \
RTP\n&quot;, sub-&gt;callid);<br> 	ast_sockaddr_from_sin(&amp;bindaddr_tmp, \
&amp;bindaddr);<br> 	sub-&gt;rtp = ast_rtp_instance_new(&quot;asterisk&quot;, sched, \
&amp;bindaddr_tmp, NULL);<br>+#if 0<br> 	if (hasvideo)<br> 		sub-&gt;vrtp = \
ast_rtp_instance_new(&quot;asterisk&quot;, sched, &amp;bindaddr_tmp, \
NULL);<br>+#endif<br> <br> 	if (sub-&gt;rtp) {<br> \
ast_rtp_instance_set_prop(sub-&gt;rtp, AST_RTP_PROPERTY_RTCP, 1);<br>@@ -4775,11 \
+4779,13 @@<br> 		ast_channel_set_fd(sub-&gt;owner, 0, \
ast_rtp_instance_fd(sub-&gt;rtp, 0));<br> 		ast_channel_set_fd(sub-&gt;owner, 1, \
ast_rtp_instance_fd(sub-&gt;rtp, 1));<br> 	}<br>+#if 0<br> 	if (hasvideo &amp;&amp; \
sub-&gt;vrtp &amp;&amp; sub-&gt;owner) {<br> \
ast_rtp_instance_set_channel_id(sub-&gt;vrtp, \
ast_channel_uniqueid(sub-&gt;owner));<br> 		ast_channel_set_fd(sub-&gt;owner, 2, \
ast_rtp_instance_fd(sub-&gt;vrtp, 0));<br> 		ast_channel_set_fd(sub-&gt;owner, 3, \
ast_rtp_instance_fd(sub-&gt;vrtp, 1));<br> 	}<br>+#endif<br> 	if (sub-&gt;rtp) {<br> \
ast_rtp_instance_set_qos(sub-&gt;rtp, qos.tos_audio, qos.cos_audio, &quot;Skinny \
RTP&quot;);<br> 		ast_rtp_instance_set_prop(sub-&gt;rtp, AST_RTP_PROPERTY_NAT, \
l-&gt;nat);<br>diff --git a/main/manager_system.c b/main/manager_system.c<br>index \
b20deea..8ef15e3 100644<br>--- a/main/manager_system.c<br>+++ \
b/main/manager_system.c<br>@@ -42,7 +42,6 @@<br> <br> int \
manager_system_init(void)<br> {<br>-	int ret = 0;<br> 	struct stasis_topic \
*manager_topic;<br> 	struct stasis_topic *system_topic;<br> 	struct \
stasis_message_router *message_router;<br>@@ -66,14 +65,6 @@<br> 	}<br> <br> \
ast_register_cleanup(manager_system_shutdown);<br>-<br>-	/* If somehow we failed to \
add any routes, just shut down the whole<br>-	 * thing and fail it.<br>-	 */<br>-	if \
(ret) {<br>-		manager_system_shutdown();<br>-		return -1;<br>-	}<br> <br> 	return \
0;<br> }<br>diff --git a/main/stdtime/localtime.c b/main/stdtime/localtime.c<br>index \
88b8020..eac199a 100644<br>--- a/main/stdtime/localtime.c<br>+++ \
b/main/stdtime/localtime.c<br>@@ -1506,16 +1506,14 @@<br> 			}<br> 		} else {<br> \
long	theirstdoffset;<br>-			long	theirdstoffset;<br> \
long	theiroffset;<br>-			int	isdst;<br> 			int	i;<br> 			int	j;<br> <br> 			if (*name \
!= &#39;\0&#39;)<br> 				return -1;<br> 			/*<br>-			** Initial values of \
theirstdoffset and theirdstoffset.<br>+			** Initial values of theirstdoffset.<br> \
*/<br> 			theirstdoffset = 0;<br> 			for (i = 0; i &lt; sp-&gt;timecnt; ++i) {<br>@@ \
-1526,19 +1524,6 @@<br> 					break;<br> 				}<br> 			}<br>-			theirdstoffset = \
0;<br>-			for (i = 0; i &lt; sp-&gt;timecnt; ++i) {<br>-				j = \
sp-&gt;types[i];<br>-				if (sp-&gt;ttis[j].tt_isdst) {<br>-					theirdstoffset \
=<br>-						-sp-&gt;ttis[j].tt_gmtoff;<br>-					break;<br>-				}<br>-			}<br>-			/*<br>-			** \
Initially we&#39;re assumed to be in standard time.<br>-			*/<br>-			isdst = \
FALSE;<br> 			theiroffset = theirstdoffset;<br> 			/*<br> 			** Now juggle transition \
times and types<br>@@ -1550,32 +1535,13 @@<br> 				if (sp-&gt;ttis[j].tt_ttisgmt) \
{<br> 					/* No adjustment to transition time */<br> 				} else \
{<br>-					/*<br>-					** If summer time is in effect, and the<br>-					** transition \
time was not specified as<br>-					** standard time, add the summer time<br>-					** \
offset to the transition time;<br>-					** otherwise, add the standard \
time<br>-					** offset to the transition time.<br>-					*/<br>-					/*<br>-					** \
Transitions from DST to DDST<br>-					** will effectively disappear since<br>-					** \
POSIX provides for only one DST<br>-					** offset.<br>-					*/<br>-					if (isdst \
&amp;&amp; !sp-&gt;ttis[j].tt_ttisstd) {<br>-						sp-&gt;ats[i] += dstoffset \
-<br>-							theirdstoffset;<br>-					} else {<br>-						sp-&gt;ats[i] += stdoffset \
-<br>-							theirstdoffset;<br>-					}<br>+					/* Add the standard time offset to \
the transition time. */<br>+					sp-&gt;ats[i] += stdoffset - theirstdoffset;<br> \
}<br> 				theiroffset = -sp-&gt;ttis[j].tt_gmtoff;<br>-				if \
(sp-&gt;ttis[j].tt_isdst)<br>-					theirdstoffset = \
theiroffset;<br>-				else	theirstdoffset = theiroffset;<br>+				if \
(!sp-&gt;ttis[j].tt_isdst) {<br>+					theirstdoffset = theiroffset;<br>+				}<br> \
}<br> 			/*<br> 			** Finally, fill in ttis.<br>diff --git a/main/xmldoc.c \
b/main/xmldoc.c<br>index e9a0afc..105bee0 100644<br>--- a/main/xmldoc.c<br>+++ \
b/main/xmldoc.c<br>@@ -1411,7 +1411,7 @@<br> static int \
xmldoc_parse_specialtags(struct ast_xml_node *fixnode, const char *tabs, const char \
*posttabs, struct ast_str **buffer)<br> {<br> 	struct ast_xml_node *node = \
fixnode;<br>-	int ret = 0, i, count = 0;<br>+	int ret = 0, i;<br> <br> 	if (!node || \
!ast_xml_node_get_children(node)) {<br> 		return ret;<br>@@ -1438,8 +1438,8 @@<br> \
/* parse &lt;para&gt; elements inside special tags. */<br> 		for (node = \
ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) {<br> \
/* first &lt;para&gt; just print it without tabs at the begining. */<br>-			if \
((xmldoc_parse_para(node, (!count ? &quot;&quot; : tabs), posttabs, buffer) == \
2)<br>-				|| (xmldoc_parse_info(node, (!count ? &quot;&quot;: tabs), posttabs, \
buffer) == 2)) {<br>+			if ((xmldoc_parse_para(node, &quot;&quot;, posttabs, buffer) \
== 2)<br>+				|| (xmldoc_parse_info(node, &quot;&quot;, posttabs, buffer) == 2)) \
{<br> 				ret = 2;<br> 			}<br> 		}<br>diff --git a/res/res_config_ldap.c \
b/res/res_config_ldap.c<br>index 8f24a8d..6d4b76d 100644<br>--- \
a/res/res_config_ldap.c<br>+++ b/res/res_config_ldap.c<br>@@ -309,8 +309,10 @@<br> \
BerElement *ber = NULL;<br> 	struct ast_variable *var = NULL;<br> 	struct \
ast_variable *prev = NULL;<br>+#if 0<br> 	int is_delimited = 0;<br> 	int i = \
0;<br>+#endif<br> 	char *ldap_attribute_name;<br> 	struct berval *value;<br> 	int pos \
= 0;<br>@@ -338,6 +340,7 @@<br> 					ast_debug(2, &quot;md5: %s\n&quot;, valptr);<br> \
}<br> 				if (valptr) {<br>+#if 0<br> 					/* ok, so looping through all delimited \
values except the last one (not, last character is not delimited...) */<br> 					if \
(is_delimited) {<br> 						i = 0;<br>@@ -358,6 +361,7 @@<br> 							i++;<br> \
}<br> 					}<br>+#endif<br> 					/* for the last delimited value or if the value is \
not delimited: */<br> 					if (prev) {<br> 						prev-&gt;next = \
ast_variable_new(attribute_name, &amp;valptr[pos], \
table_config-&gt;table_name);<br></pre><p>To view, visit <a \
href="https://gerrit.asterisk.org/7629">change 7629</a>. To unsubscribe, visit <a \
href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope \
itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" \
itemtype="http://schema.org/ViewAction"><link itemprop="url" \
href="https://gerrit.asterisk.org/7629"/><meta itemprop="name" content="View \
Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: \
I62e2aac353d739fb3c983cf768933120f5fba059 </div> <div style="display:none"> \
Gerrit-Change-Number: 7629 </div> <div style="display:none"> Gerrit-PatchSet: 4 \
</div> <div style="display:none"> Gerrit-Owner: Corey Farrell &lt;git@cfware.com&gt; \
</div> <div style="display:none"> Gerrit-Reviewer: Corey Farrell \
&lt;git@cfware.com&gt; </div> <div style="display:none"> Gerrit-Reviewer: Jenkins2 \
</div> <div style="display:none"> Gerrit-Reviewer: Kevin Harwell \
&lt;kharwell@digium.com&gt; </div> <div style="display:none"> Gerrit-Reviewer: \
Richard Mudgett &lt;rmudgett@digium.com&gt; </div>



-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-commits
--===============4234465867770281659==--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic