[asterisk-bugs] [Asterisk 0014127]: Enumerated type and integer comparison do not work as you might expect

Asterisk Bug Tracker noreply at bugs.digium.com
Mon Dec 22 22:05:21 CST 2008


The following issue has been RESOLVED. 
====================================================================== 
http://bugs.digium.com/view.php?id=14127 
====================================================================== 
Reported By:                andrew
Assigned To:                svnbot
====================================================================== 
Project:                    Asterisk
Issue ID:                   14127
Category:                   Core/Channels
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     resolved
Asterisk Version:           SVN 
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!): 16420 
Disclaimer on File?:        N/A 
Request Review:              
Resolution:                 fixed
Fixed in Version:           
====================================================================== 
Date Submitted:             2008-12-22 18:04 CST
Last Modified:              2008-12-22 22:05 CST
====================================================================== 
Summary:                    Enumerated type and integer comparison do not work
as you might expect
Description: 
In main/channel.c there is a section of code (about line 2530):
+        if (condition < 0) {
+                /* Stop any tones that are playing */
+                ast_playtones_stop(chan);
+                return 0;
+        }

Where "condition" is an enumerated type. It seems logical that you can
compare ordinal position of the value of variable (which is a number) to an
integer, but it does not work. If the integer value of condition is -1 then
the statement should evaluate as should be "true", but does is not (at
least on my system). If you change the code to cast "condition" as an
integer:
+        if ((int)condition < 0) {
then the comparison works as expected.


====================================================================== 

---------------------------------------------------------------------- 
 (0096870) svnbot (reporter) - 2008-12-22 22:05
 http://bugs.digium.com/view.php?id=14127#c96870 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 166509

U   branches/1.4/main/channel.c

------------------------------------------------------------------------
r166509 | tilghman | 2008-12-22 22:05:21 -0600 (Mon, 22 Dec 2008) | 4
lines

Use the integer form of condition for integer comparisons.
(closes issue http://bugs.digium.com/view.php?id=14127)
 Reported by: andrew

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=166509 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-12-22 22:05 svnbot         Checkin                                      
2008-12-22 22:05 svnbot         Note Added: 0096870                          
2008-12-22 22:05 svnbot         Status                   new => resolved     
2008-12-22 22:05 svnbot         Resolution               open => fixed       
2008-12-22 22:05 svnbot         Assigned To               => svnbot          
======================================================================




More information about the asterisk-bugs mailing list