[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:32:24 CST 2008


A NOTE has been added to this issue. 
====================================================================== 
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:                     closed
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:32 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.


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

---------------------------------------------------------------------- 
 (0096871) svnbot (reporter) - 2008-12-22 22:32
 http://bugs.digium.com/view.php?id=14127#c96871 
---------------------------------------------------------------------- 
Repository: asterisk
Revision: 166533

_U  trunk/
U   trunk/main/channel.c

------------------------------------------------------------------------
r166533 | tilghman | 2008-12-22 22:32:23 -0600 (Mon, 22 Dec 2008) | 11
lines

Merged revisions 166509 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r166509 | tilghman | 2008-12-22 22:05:25 -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=166533 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-12-22 22:32 svnbot         Checkin                                      
2008-12-22 22:32 svnbot         Note Added: 0096871                          
======================================================================




More information about the asterisk-bugs mailing list