[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 18:04:12 CST 2008


The following issue has been SUBMITTED. 
====================================================================== 
http://bugs.digium.com/view.php?id=14127 
====================================================================== 
Reported By:                andrew
Assigned To:                
====================================================================== 
Project:                    Asterisk
Issue ID:                   14127
Category:                   Core/Channels
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
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:              
====================================================================== 
Date Submitted:             2008-12-22 18:04 CST
Last Modified:              2008-12-22 18:04 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.


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

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-12-22 18:04 andrew         New Issue                                    
2008-12-22 18:04 andrew         Asterisk Version          => SVN             
2008-12-22 18:04 andrew         SVN Branch (only for SVN checkouts, not tarball
releases) => N/A             
2008-12-22 18:04 andrew         SVN Revision (number only!) => 16420           
======================================================================




More information about the asterisk-bugs mailing list