summaryrefslogtreecommitdiff
path: root/main/event.c
diff options
context:
space:
mode:
authorDiederik de Groot <ddegroot@talon.nl>2015-04-23 15:00:42 +0200
committerDiederik de Groot <ddegroot@talon.nl>2015-04-23 18:26:55 +0200
commit1bb16bedc72d5cf6fc95cda3bd60c440285575d7 (patch)
tree3b5d7f82d6103c7c10c8f02393f7126ae0b7e481 /main/event.c
parentd08446ec36600348090eb2451c5a9a7aadd633de (diff)
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
Diffstat (limited to 'main/event.c')
-rw-r--r--main/event.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main/event.c b/main/event.c
index 8880b9699..019dfcac0 100644
--- a/main/event.c
+++ b/main/event.c
@@ -199,7 +199,7 @@ const char *ast_event_get_type_name(const struct ast_event *event)
type = ast_event_get_type(event);
- if (type >= ARRAY_LEN(event_names)) {
+ if ((unsigned int)type >= ARRAY_LEN(event_names)) {
ast_log(LOG_ERROR, "Invalid event type - '%u'\n", type);
return "";
}