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 /channels | |
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 'channels')
-rw-r--r-- | channels/chan_skinny.c | 6 | ||||
-rw-r--r-- | channels/pjsip/dialplan_functions.c | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index fb51996ab..a089c65d8 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -2374,6 +2374,7 @@ static char *callstate2str(int ind) static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) { int res = 0; + unsigned long len; if (!s) { ast_log(LOG_WARNING, "Asked to transmit to a non-existent session!\n"); @@ -2382,7 +2383,10 @@ static int transmit_response_bysession(struct skinnysession *s, struct skinny_re ast_mutex_lock(&s->lock); - if ((letohl(req->len) > SKINNY_MAX_PACKET) || (letohl(req->len) < 0)) { + /* Don't optimize out assigning letohl() to len. It is necessary to guarantee that the comparison will always catch invalid values. + * letohl() may or may not return a signed value depending upon which definition is used. */ + len = letohl(req->len); + if (SKINNY_MAX_PACKET < len) { ast_log(LOG_WARNING, "transmit_response: the length of the request (%u) is out of bounds (%d)\n", letohl(req->len), SKINNY_MAX_PACKET); ast_mutex_unlock(&s->lock); return -1; diff --git a/channels/pjsip/dialplan_functions.c b/channels/pjsip/dialplan_functions.c index 567cd59ee..9c5245648 100644 --- a/channels/pjsip/dialplan_functions.c +++ b/channels/pjsip/dialplan_functions.c @@ -866,11 +866,11 @@ static int media_offer_read_av(struct ast_sip_session *session, char *buf, /* add one since we'll include a comma */ size = strlen(ast_format_get_name(fmt)) + 1; - len -= size; - if ((len) < 0) { + if (len < size) { ao2_ref(fmt, -1); break; } + len -= size; /* no reason to use strncat here since we have already ensured buf has enough space, so strcat can be safely used */ |