]> git.ipfire.org Git - thirdparty/asterisk.git/commit
Clang: change previous tautological-compare fixes. 35/235/1
authorDiederik de Groot <ddegroot@talon.nl>
Thu, 23 Apr 2015 13:00:42 +0000 (15:00 +0200)
committerMatt Jordan <mjordan@digium.com>
Thu, 23 Apr 2015 16:54:09 +0000 (11:54 -0500)
commit9c61245061dbd96d96acb608a5b0f6e77d1472f2
treee984bc971ab596cc0fcbbb101642f38147142a75
parentf56c5f1aa22e904226e4cad43e8bbc57f43f31b3
Clang: change previous tautological-compare fixes.

clang can warn about a so called tautological-compare, when it finds
comparisons which are logically always true, and are therefor deemed
unnecessary.

Exanple:
unsigned int x = 4;
if (x > 0)    // x is always going to be bigger than 0

Enum Case:
Each enumeration is its own type. Enums are an integer type but they
do not have to be *signed*. C leaves it up to the compiler as an
implementation option what to consider the integer type of a particu-
lar enumeration is. Gcc treats an enum without negative values as
an int while clang treats this enum as an unsigned int.

rmudgett & mmichelson: cast the enum to (unsigned int) in assert.
The cast does have an effect. For gcc, which seems to treat all enums
as int, the cast to unsigned int will eliminate the possibility of
negative values being allowed. For clang, which seems to treat enums
without any negative members as unsigned int, the cast will have no
effect. If for some reason in the future a negative value is ever
added to the enum the assert will still catch the negative value.

ASTERISK-24917

Change-Id: I0557ae0154a0b7de68883848a609309cdf0aee6a
main/event.c
main/security_events.c