diff options
author | Matthew Jordan <mjordan@digium.com> | 2015-04-09 12:56:30 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2015-04-09 12:56:30 +0000 |
commit | 6ba6e3dffd57f1c62c0c7f9a9030c1f41b5a6350 (patch) | |
tree | a37689439efaf52dad71e900bdb725c43654e46e /main | |
parent | e05c8ae68e95367ea60fdc5e8a5f2cf7f24e0f32 (diff) |
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.
* res_pjsip_exten_state: Use a temporary value to cache the return of
ast_hint_presence_state
* res_stasis_playback: Fix enum comparisons where the enum can never be
negative
* res_stasis_recording: Add an enum value for the case where the recording
operation is in error; fix enum comparisons
* resource_bridges: Use enum value as opposed to -1
* resource_channels: Use enum value as opposed to -1
Review: https://reviewboard.asterisk.org/r/4533
ASTERISK-24917
Reported by: dkdegroot
patches:
rb4533.patch submitted by dkdegroot (License 6600)
........
Merged revisions 434469 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434470 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 3 | ||||
-rw-r--r-- | main/cel.c | 16 | ||||
-rw-r--r-- | main/enum.c | 2 | ||||
-rw-r--r-- | main/event.c | 2 | ||||
-rw-r--r-- | main/indications.c | 5 | ||||
-rw-r--r-- | main/presencestate.c | 2 | ||||
-rw-r--r-- | main/security_events.c | 4 | ||||
-rw-r--r-- | main/udptl.c | 9 |
8 files changed, 19 insertions, 24 deletions
diff --git a/main/app.c b/main/app.c index 44d61ef5b..8c33b9146 100644 --- a/main/app.c +++ b/main/app.c @@ -1515,6 +1515,9 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, case AST_RECORD_IF_EXISTS_APPEND: ioflags |= O_APPEND; break; + case AST_RECORD_IF_EXISTS_ERROR: + ast_assert(0); + break; } if (silencethreshold < 0) { diff --git a/main/cel.c b/main/cel.c index 93655c741..0c1e37b68 100644 --- a/main/cel.c +++ b/main/cel.c @@ -284,7 +284,7 @@ static struct aco_type *general_options[] = ACO_TYPES(&general_option); * \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", @@ -524,16 +524,13 @@ 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; } } - return -1; + ast_log(LOG_ERROR, "Unknown event name '%s'\n", name); + return AST_CEL_INVALID_VALUE; } static int ast_cel_track_event(enum ast_cel_event_type et) @@ -563,11 +560,10 @@ static int events_handler(const struct aco_option *opt, struct ast_variable *var event_type = ast_cel_str_to_event_type(cur_event); - if (event_type == 0) { + if (event_type == AST_CEL_ALL) { /* All events */ cfg->events = (int64_t) -1; - } else if (event_type == -1) { - ast_log(LOG_ERROR, "Unknown event name '%s'\n", cur_event); + } else if (event_type == AST_CEL_INVALID_VALUE) { return -1; } else { cfg->events |= ((int64_t) 1 << event_type); diff --git a/main/enum.c b/main/enum.c index e36a9c745..bae129965 100644 --- a/main/enum.c +++ b/main/enum.c @@ -257,7 +257,7 @@ struct ebl_context { static int ebl_callback(void *context, unsigned char *answer, int len, unsigned char *fullanswer) { struct ebl_context *c = context; - unsigned int i; + int i; c->pos = 0; /* default to empty */ c->separator[0] = 0; diff --git a/main/event.c b/main/event.c index 92adc0368..8880b9699 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 < 0 || type >= ARRAY_LEN(event_names)) { + if (type >= ARRAY_LEN(event_names)) { ast_log(LOG_ERROR, "Invalid event type - '%u'\n", type); return ""; } diff --git a/main/indications.c b/main/indications.c index af9cfc8ef..02a68b7ca 100644 --- a/main/indications.c +++ b/main/indications.c @@ -359,14 +359,13 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, if (tone_data.midinote) { /* midi notes must be between 0 and 127 */ - - if (tone_data.freq1 >= 0 && tone_data.freq1 <= 127) { + if (tone_data.freq1 <= 127) { tone_data.freq1 = midi_tohz[tone_data.freq1]; } else { tone_data.freq1 = 0; } - if (tone_data.freq2 >= 0 && tone_data.freq2 <= 127) { + if (tone_data.freq2 <= 127) { tone_data.freq2 = midi_tohz[tone_data.freq2]; } else { tone_data.freq2 = 0; diff --git a/main/presencestate.c b/main/presencestate.c index 07df7429d..ab03336e2 100644 --- a/main/presencestate.c +++ b/main/presencestate.c @@ -290,7 +290,7 @@ static void do_presence_state_change(const char *provider) state = ast_presence_state_helper(provider, &subtype, &message, 0); - if (state < 0) { + if (state == AST_PRESENCE_INVALID) { return; } diff --git a/main/security_events.c b/main/security_events.c index 0546bfe73..5a8df66d1 100644 --- a/main/security_events.c +++ b/main/security_events.c @@ -886,7 +886,7 @@ const char *ast_security_event_severity_get_name( static int check_event_type(const enum ast_security_event_type event_type) { - if (event_type < 0 || event_type >= AST_SECURITY_EVENT_NUM_TYPES) { + if (event_type >= AST_SECURITY_EVENT_NUM_TYPES) { ast_log(LOG_ERROR, "Invalid security event type %u\n", event_type); return -1; } @@ -1172,7 +1172,7 @@ return_error: int ast_security_event_report(const struct ast_security_event_common *sec) { - if (sec->event_type < 0 || sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) { + if (sec->event_type >= AST_SECURITY_EVENT_NUM_TYPES) { ast_log(LOG_ERROR, "Invalid security event type\n"); return -1; } diff --git a/main/udptl.c b/main/udptl.c index 91458489d..4e878195c 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -362,8 +362,7 @@ static int encode_open_type(const struct ast_udptl *udptl, uint8_t *buf, unsigne } /* Encode the open type */ for (octet_idx = 0; ; num_octets -= enclen, octet_idx += enclen) { - if ((enclen = encode_length(buf, len, num_octets)) < 0) - return -1; + enclen = encode_length(buf, len, num_octets); if (enclen + *len > buflen) { ast_log(LOG_ERROR, "UDPTL (%s): Buffer overflow detected (%u + %u > %u)\n", LOG_TAG(udptl), enclen, *len, buflen); @@ -646,8 +645,7 @@ static int udptl_build_packet(struct ast_udptl *s, uint8_t *buf, unsigned int bu buf[len++] = 0x00; /* The number of entries will always be zero, so it is pointless allowing for the fragmented case here. */ - if (encode_length(buf, &len, 0) < 0) - return -1; + encode_length(buf, &len, 0); break; case UDPTL_ERROR_CORRECTION_REDUNDANCY: /* Encode the error recovery type */ @@ -658,8 +656,7 @@ static int udptl_build_packet(struct ast_udptl *s, uint8_t *buf, unsigned int bu entries = s->tx_seq_no; /* The number of entries will always be small, so it is pointless allowing for the fragmented case here. */ - if (encode_length(buf, &len, entries) < 0) - return -1; + encode_length(buf, &len, entries); /* Encode the elements */ for (i = 0; i < entries; i++) { j = (entry - i - 1) & UDPTL_BUF_MASK; |