clang compiler warnings: Fix autological comparisons

This fixes autological comparison warnings in the following:
 * chan_skinny: letohl may return a signed or unsigned value, depending on the
   macro chosen
 * func_curl: Provide a specific cast to CURLoption to prevent mismatch
 * cel: Fix enum comparisons where the enum can never be negative
 * enum: Fix comparison of return result of dn_expand, which returns a signed
   int value
 * event: Fix enum comparisons where the enum can never be negative
 * indications: tone_data.freq1 and freq2 are unsigned, and hence can never be
   negative
 * presencestate: Use the actual enum value for INVALID state
 * security_events: Fix enum comparisons where the enum can never be negative
 * udptl: Don't bother to check if the return value from encode_length is less
   than 0, as it returns an unsigned int
 * translate: Since the parameters are unsigned int, don't bother checking
   to see if they are negative. The cast to unsigned int would already blow
   past the matrix bounds.

Review: https://reviewboard.asterisk.org/r/4533
ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4533.patch submitted by dkdegroot (License 6600)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@434469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2015-04-09 12:47:09 +00:00
parent 6b399f72dc
commit 7c4efc490a
11 changed files with 33 additions and 31 deletions

View File

@@ -123,7 +123,7 @@ static char cel_dateformat[256];
* \brief Map of ast_cel_event_type to strings
*/
static const char * const cel_event_types[CEL_MAX_EVENT_IDS] = {
[0] = "ALL",
[AST_CEL_ALL] = "ALL",
[AST_CEL_CHANNEL_START] = "CHAN_START",
[AST_CEL_CHANNEL_END] = "CHAN_END",
[AST_CEL_ANSWER] = "ANSWER",
@@ -256,15 +256,12 @@ enum ast_cel_event_type ast_cel_str_to_event_type(const char *name)
unsigned int i;
for (i = 0; i < ARRAY_LEN(cel_event_types); i++) {
if (!cel_event_types[i]) {
continue;
}
if (!strcasecmp(name, cel_event_types[i])) {
if (cel_event_types[i] && !strcasecmp(name, cel_event_types[i])) {
return i;
}
}
ast_log(LOG_ERROR, "Unknown event name '%s'\n", name);
return -1;
}
@@ -288,10 +285,10 @@ static void parse_events(const char *val)
event_type = ast_cel_str_to_event_type(cur_event);
if (event_type == 0) {
if (event_type == AST_CEL_ALL) {
/* All events */
eventset = (int64_t) -1;
} else if (event_type == -1) {
} else if (event_type == AST_CEL_INVALID_VALUE) {
ast_log(LOG_WARNING, "Unknown event name '%s'\n",
cur_event);
} else {
@@ -416,7 +413,7 @@ const char *ast_cel_get_type_name(enum ast_cel_event_type type)
const char *ast_cel_get_ama_flag_name(enum ast_cel_ama_flag flag)
{
if (flag < 0 || flag >= ARRAY_LEN(cel_ama_flags)) {
if (flag >= ARRAY_LEN(cel_ama_flags)) {
ast_log(LOG_WARNING, "Invalid AMA flag: %u\n", flag);
return "Unknown";
}