summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-05-10 20:56:09 +0000
committerKinsey Moore <kmoore@digium.com>2012-05-10 20:56:09 +0000
commitdd81b047dbf15a501b81354db505daf50703a1a0 (patch)
tree01754d4206c865653717baf23e47ed264f7a6b3d /funcs
parent8227f70cd70f497cb03c1f9aab63950bcd979d8b (diff)
Resolve FORWARD_NULL static analysis warnings
This resolves core findings from ASTERISK-19650 numbers 0-2, 6, 7, 9-11, 14-20, 22-24, 28, 30-32, 34-36, 42-56, 82-84, 87, 89-90, 93-102, 104, 105, 109-111, and 115. Finding numbers 26, 33, and 29 were already resolved. Those skipped were either extended/deprecated or in areas of code that shouldn't be disturbed. (Closes issue ASTERISK-19650) ........ Merged revisions 366167 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 366168 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366169 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_lock.c29
-rw-r--r--funcs/func_speex.c14
2 files changed, 22 insertions, 21 deletions
diff --git a/funcs/func_lock.c b/funcs/func_lock.c
index 060fcb809..9394b3918 100644
--- a/funcs/func_lock.c
+++ b/funcs/func_lock.c
@@ -373,10 +373,15 @@ static int get_lock(struct ast_channel *chan, char *lockname, int trylock)
static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- struct ast_datastore *lock_store = ast_channel_datastore_find(chan, &lock_info, NULL);
+ struct ast_datastore *lock_store;
struct channel_lock_frame *clframe;
AST_LIST_HEAD(, channel_lock_frame) *list;
+ if (!chan) {
+ return -1;
+ }
+
+ lock_store = ast_channel_datastore_find(chan, &lock_info, NULL);
if (!lock_store) {
ast_log(LOG_WARNING, "No datastore for dialplan locks. Nothing was ever locked!\n");
ast_copy_string(buf, "0", len);
@@ -417,26 +422,24 @@ static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, ch
static int lock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- if (chan)
- ast_autoservice_start(chan);
-
+ if (!chan) {
+ return -1;
+ }
+ ast_autoservice_start(chan);
ast_copy_string(buf, get_lock(chan, data, 0) ? "0" : "1", len);
-
- if (chan)
- ast_autoservice_stop(chan);
+ ast_autoservice_stop(chan);
return 0;
}
static int trylock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- if (chan)
- ast_autoservice_start(chan);
-
+ if (!chan) {
+ return -1;
+ }
+ ast_autoservice_start(chan);
ast_copy_string(buf, get_lock(chan, data, 1) ? "0" : "1", len);
-
- if (chan)
- ast_autoservice_stop(chan);
+ ast_autoservice_stop(chan);
return 0;
}
diff --git a/funcs/func_speex.c b/funcs/func_speex.c
index 2b29271f3..fb5addbb4 100644
--- a/funcs/func_speex.c
+++ b/funcs/func_speex.c
@@ -202,6 +202,11 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
struct speex_direction_info **sdi = NULL;
int is_new = 0;
+ if (strcasecmp(data, "rx") && strcasecmp(data, "tx")) {
+ ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
+ return -1;
+ }
+
ast_channel_lock(chan);
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
ast_channel_unlock(chan);
@@ -226,15 +231,8 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
if (!strcasecmp(data, "rx")) {
sdi = &si->rx;
- } else if (!strcasecmp(data, "tx")) {
- sdi = &si->tx;
} else {
- ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
-
- if (is_new) {
- ast_datastore_free(datastore);
- return -1;
- }
+ sdi = &si->tx;
}
if (!*sdi) {