Skip to content
Snippets Groups Projects
Commit 3bb1e967 authored by Matt Jordan's avatar Matt Jordan
Browse files

Clang: Fix some more tautological-compare warnings.

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

Example:
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 particular 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: Ief23ef68916192b9b72dabe702b543ecfeca0b62
parent 9c612450
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment