aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-10 13:22:15 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-10 13:22:15 +0000
commitd99b677f3501944b7aaf82375ef62a88e5fa3933 (patch)
tree167bf7a9b6b330883dc9bf865672132658710ffd
parenta6b2177d50659d049694ca79f6cbe00f54dd0a93 (diff)
remove almost all of the checks of the result from ast_strdupa() or alloca().
As it turns out, all of these checks were useless, because alloca will never return NULL. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@26451 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--app.c13
-rw-r--r--apps/app_amd.c7
-rw-r--r--apps/app_authenticate.c5
-rw-r--r--apps/app_db.c10
-rw-r--r--apps/app_dial.c6
-rw-r--r--apps/app_dictate.c3
-rw-r--r--apps/app_directory.c5
-rw-r--r--apps/app_disa.c5
-rw-r--r--apps/app_exec.c78
-rw-r--r--apps/app_externalivr.c5
-rw-r--r--apps/app_festival.c6
-rw-r--r--apps/app_hasnewvoicemail.c5
-rw-r--r--apps/app_image.c5
-rw-r--r--apps/app_mixmonitor.c5
-rw-r--r--apps/app_osplookup.c24
-rw-r--r--apps/app_page.c5
-rw-r--r--apps/app_playback.c5
-rw-r--r--apps/app_privacy.c5
-rw-r--r--apps/app_queue.c16
-rw-r--r--apps/app_random.c5
-rw-r--r--apps/app_read.c5
-rw-r--r--apps/app_readfile.c5
-rw-r--r--apps/app_realtime.c34
-rw-r--r--apps/app_record.c5
-rw-r--r--apps/app_sayunixtime.c3
-rw-r--r--apps/app_senddtmf.c5
-rw-r--r--apps/app_sendtext.c8
-rw-r--r--apps/app_setcallerid.c5
-rw-r--r--apps/app_skel.c5
-rw-r--r--apps/app_speech_utils.c6
-rw-r--r--apps/app_stack.c3
-rw-r--r--apps/app_talkdetect.c5
-rw-r--r--apps/app_transfer.c8
-rw-r--r--apps/app_url.c5
-rw-r--r--apps/app_userevent.c5
-rw-r--r--apps/app_verbose.c57
-rw-r--r--apps/app_voicemail.c80
-rw-r--r--apps/app_while.c5
-rw-r--r--apps/app_zapras.c5
-rw-r--r--apps/app_zapscan.c2
-rw-r--r--callerid.c5
-rw-r--r--channel.c9
-rw-r--r--channels/chan_agent.c11
-rw-r--r--channels/chan_iax2.c24
-rw-r--r--channels/chan_sip.c89
-rw-r--r--dsp.c14
-rw-r--r--funcs/func_cut.c8
-rw-r--r--include/asterisk/utils.h7
-rw-r--r--indications.c5
-rw-r--r--loader.c3
-rw-r--r--logger.c5
-rw-r--r--manager.c3
-rw-r--r--netsock.c4
-rw-r--r--pbx.c27
-rw-r--r--pbx/pbx_dundi.c3
-rw-r--r--res/res_agi.c2
-rw-r--r--res/res_clioriginate.c9
-rw-r--r--res/res_config_odbc.c2
-rw-r--r--res/res_config_pgsql.c2
-rw-r--r--res/res_convert.c4
-rw-r--r--res/res_features.c61
-rw-r--r--res/res_monitor.c32
-rw-r--r--strcompat.c3
63 files changed, 283 insertions, 523 deletions
diff --git a/app.c b/app.c
index afc621390..dcd4d6dc7 100644
--- a/app.c
+++ b/app.c
@@ -523,7 +523,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
ast_log(LOG_DEBUG,"Recording Formats: sfmts=%s\n", fmts);
sfmt[0] = ast_strdupa(fmts);
- while((fmt = strsep(&stringp, "|"))) {
+ while ((fmt = strsep(&stringp, "|"))) {
if (fmtcnt > MAX_OTHER_FORMATS - 1) {
ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app.c\n");
break;
@@ -1092,13 +1092,12 @@ static int ivr_dispatch(struct ast_channel *chan, struct ast_ivr_option *option,
case AST_ACTION_BACKLIST:
res = 0;
c = ast_strdupa(option->adata);
- if (c) {
- while((n = strsep(&c, ";")))
- if ((res = ast_stream_and_wait(chan, n, chan->language,
- (option->action == AST_ACTION_BACKLIST) ? AST_DIGIT_ANY : "")))
- break;
- ast_stopstream(chan);
+ while ((n = strsep(&c, ";"))) {
+ if ((res = ast_stream_and_wait(chan, n, chan->language,
+ (option->action == AST_ACTION_BACKLIST) ? AST_DIGIT_ANY : "")))
+ break;
}
+ ast_stopstream(chan);
return res;
default:
ast_log(LOG_NOTICE, "Unknown dispatch function %d, ignoring!\n", option->action);
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 16fc6bf64..b79f823d9 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -140,12 +140,7 @@ static void isAnsweringMachine(struct ast_channel *chan, void *data)
ast_log(LOG_NOTICE, "AMD using the default parameters.\n");
} else {
/* Some arguments have been passed. Lets parse them and overwrite the defaults. */
- if (!(parse = ast_strdupa(data))) {
- ast_log(LOG_WARNING, "Memory allocation failure\n");
- pbx_builtin_setvar_helper(chan , "AMDSTATUS" , "" );
- pbx_builtin_setvar_helper(chan , "AMDCAUSE" , "" );
- return;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_authenticate.c b/apps/app_authenticate.c
index eb3b7184d..bb67fb194 100644
--- a/apps/app_authenticate.c
+++ b/apps/app_authenticate.c
@@ -123,10 +123,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
}
}
- if (!(argcopy = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ argcopy = ast_strdupa(data);
AST_STANDARD_APP_ARGS(arglist,argcopy);
diff --git a/apps/app_db.c b/apps/app_db.c
index bb4bcbd9c..4c5f5c6fa 100644
--- a/apps/app_db.c
+++ b/apps/app_db.c
@@ -71,10 +71,7 @@ static int deltree_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(argv = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return 0;
- }
+ argv = ast_strdupa(data);
if (strchr(argv, '/')) {
family = strsep(&argv, "/");
@@ -115,10 +112,7 @@ static int del_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(argv = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return 0;
- }
+ argv = ast_strdupa(data);
if (strchr(argv, '/')) {
family = strsep(&argv, "/");
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 7d97187e3..b3fe1c023 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -787,8 +787,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
LOCAL_USER_ADD(u);
- if (!(parse = ast_strdupa(data)))
- goto done;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -1596,8 +1595,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(announce = ast_strdupa(data)))
- goto done;
+ announce = ast_strdupa(data);
memset(&peerflags, 0, sizeof(peerflags));
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index 95f814096..769121dc7 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -107,8 +107,7 @@ static int dictate_exec(struct ast_channel *chan, void *data)
snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
if (!ast_strlen_zero(data)) {
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
} else
args.argc = 0;
diff --git a/apps/app_directory.c b/apps/app_directory.c
index d5851d9da..0dc7dc1c5 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -411,10 +411,7 @@ static int directory_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_disa.c b/apps/app_disa.c
index d7c3a5872..b49fe47a6 100644
--- a/apps/app_disa.c
+++ b/apps/app_disa.c
@@ -158,10 +158,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
- if (!(tmp = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
diff --git a/apps/app_exec.c b/apps/app_exec.c
index d41bf27b3..e9564b19d 100644
--- a/apps/app_exec.c
+++ b/apps/app_exec.c
@@ -80,8 +80,7 @@ static char *tryexec_descrip =
"The channel variable TRYSTATUS will be set to:\n"
" SUCCESS if the application returned zero\n"
" FAILED if the application returned non-zero\n"
-" NOAPP if the application was not found or was not specified\n"
-" NOMEMORY if there was not enough memory to execute.\n";
+" NOAPP if the application was not found or was not specified\n";
static char *app_execif = "ExecIf";
static char *execif_synopsis = "Executes dialplan application, conditionally";
@@ -104,25 +103,23 @@ static int exec_exec(struct ast_channel *chan, void *data)
/* Check and parse arguments */
if (data) {
- if ((s = ast_strdupa(data))) {
- appname = strsep(&s, "(");
- if (s) {
- endargs = strrchr(s, ')');
- if (endargs)
- *endargs = '\0';
- pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
- }
- if (appname) {
- app = pbx_findapp(appname);
- if (app) {
- res = pbx_exec(chan, app, args);
- } else {
- ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
- res = -1;
- }
+ s = ast_strdupa(data);
+ appname = strsep(&s, "(");
+ if (s) {
+ endargs = strrchr(s, ')');
+ if (endargs)
+ *endargs = '\0';
+ pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+ }
+ if (appname) {
+ app = pbx_findapp(appname);
+ if (app) {
+ res = pbx_exec(chan, app, args);
+ } else {
+ ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+ res = -1;
}
- } else
- res = -1;
+ }
}
LOCAL_USER_REMOVE(u);
@@ -140,27 +137,23 @@ static int tryexec_exec(struct ast_channel *chan, void *data)
/* Check and parse arguments */
if (data) {
- if ((s = ast_strdupa(data))) {
- appname = strsep(&s, "(");
- if (s) {
- endargs = strrchr(s, ')');
- if (endargs)
- *endargs = '\0';
- pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
- }
- if (appname) {
- app = pbx_findapp(appname);
- if (app) {
- res = pbx_exec(chan, app, args);
- pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
- } else {
- ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
- pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
- }
+ s = ast_strdupa(data);
+ appname = strsep(&s, "(");
+ if (s) {
+ endargs = strrchr(s, ')');
+ if (endargs)
+ *endargs = '\0';
+ pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
+ }
+ if (appname) {
+ app = pbx_findapp(appname);
+ if (app) {
+ res = pbx_exec(chan, app, args);
+ pbx_builtin_setvar_helper(chan, "TRYSTATUS", res ? "FAILED" : "SUCCESS");
+ } else {
+ ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
+ pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOAPP");
}
- } else {
- ast_log(LOG_ERROR, "Out of memory\n");
- pbx_builtin_setvar_helper(chan, "TRYSTATUS", "NOMEMORY");
}
}
@@ -178,10 +171,7 @@ static int execif_exec(struct ast_channel *chan, void *data) {
LOCAL_USER_ADD(u);
- if (!(expr = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ expr = ast_strdupa(data);
if ((myapp = strchr(expr,'|'))) {
*myapp = '\0';
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index 7a9757ed1..ecc8bf888 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -275,10 +275,7 @@ static int app_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (!(buf = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(lu);
- return -1;
- }
+ buf = ast_strdupa(data);
argc = ast_app_separate_args(buf, '|', argv, sizeof(argv) / sizeof(argv[0]));
diff --git a/apps/app_festival.c b/apps/app_festival.c
index cb38d42fd..5a4bb053e 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -356,11 +356,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
festivalcommand = newfestivalcommand;
}
- if (!(data = ast_strdupa(vdata))) {
- ast_config_destroy(cfg);
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ data = ast_strdupa(vdata);
intstr = strchr(data, '|');
if (intstr) {
diff --git a/apps/app_hasnewvoicemail.c b/apps/app_hasnewvoicemail.c
index f21bd7ae6..2bc730e10 100644
--- a/apps/app_hasnewvoicemail.c
+++ b/apps/app_hasnewvoicemail.c
@@ -126,10 +126,7 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(input = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ input = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, input);
diff --git a/apps/app_image.c b/apps/app_image.c
index 9e69bd4cd..51389a676 100644
--- a/apps/app_image.c
+++ b/apps/app_image.c
@@ -76,10 +76,7 @@ static int sendimage_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_mixmonitor.c b/apps/app_mixmonitor.c
index 7b16d48e9..324c3a3cf 100644
--- a/apps/app_mixmonitor.c
+++ b/apps/app_mixmonitor.c
@@ -338,10 +338,7 @@ static int mixmonitor_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index 7c09fee02..649798380 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -137,11 +137,7 @@ static int ospauth_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Out of memory\n");
- LOCAL_USER_REMOVE(u);
- return(-1);
- }
+ tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
@@ -232,11 +228,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Out of memory\n");
- LOCAL_USER_REMOVE(u);
- return(-1);
- }
+ tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
@@ -382,11 +374,7 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Out of memory\n");
- LOCAL_USER_REMOVE(u);
- return(-1);
- }
+ tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
@@ -506,11 +494,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- ast_log(LOG_ERROR, "Out of memory\n");
- LOCAL_USER_REMOVE(u);
- return(-1);
- }
+ tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
diff --git a/apps/app_page.c b/apps/app_page.c
index 7184ab9ad..cbc9b23c0 100644
--- a/apps/app_page.c
+++ b/apps/app_page.c
@@ -167,10 +167,7 @@ static int page_exec(struct ast_channel *chan, void *data)
return -1;
};
- if (!(options = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ options = ast_strdupa(data);
ast_copy_string(originator, chan->name, sizeof(originator));
if ((tmp = strchr(originator, '-')))
diff --git a/apps/app_playback.c b/apps/app_playback.c
index 2816d53df..abf9cd613 100644
--- a/apps/app_playback.c
+++ b/apps/app_playback.c
@@ -167,8 +167,6 @@ static int do_say(say_args_t *a, const char *s, const char *options, int depth)
a->language = "en"; /* default */
ast_log(LOG_WARNING, "try <%s> in <%s>\n", s, a->language);
lang = ast_strdupa(a->language);
- if (!lang) /* no memory! */
- return -1;
for (;;) {
for (v = ast_variable_browse(say_cfg, lang); v ; v = v->next) {
if (ast_extension_match(v->name, s)) {
@@ -401,8 +399,7 @@ static int playback_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (!(tmp = ast_strdupa(data)))
- return -1;
+ tmp = ast_strdupa(data);
LOCAL_USER_ADD(u);
AST_STANDARD_APP_ARGS(args, tmp);
diff --git a/apps/app_privacy.c b/apps/app_privacy.c
index 00af9fc27..c1a0ea8e2 100644
--- a/apps/app_privacy.c
+++ b/apps/app_privacy.c
@@ -113,10 +113,7 @@ static int privacy_exec (struct ast_channel *chan, void *data)
if (!ast_strlen_zero((char *)data))
{
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 25329a938..c19b18727 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2769,8 +2769,7 @@ static int pqm_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -2822,8 +2821,7 @@ static int upqm_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -2877,8 +2875,7 @@ static int rqm_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -2942,8 +2939,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
return -1;
}
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -3029,10 +3025,6 @@ static int queue_exec(struct ast_channel *chan, void *data)
}
parse = ast_strdupa(data);
- if (!parse) {
- ast_log(LOG_ERROR, "Out of memory!\n");
- return -1;
- }
AST_STANDARD_APP_ARGS(args, parse);
LOCAL_USER_ADD(lu);
diff --git a/apps/app_random.c b/apps/app_random.c
index 9809a533b..9b9fac884 100644
--- a/apps/app_random.c
+++ b/apps/app_random.c
@@ -71,10 +71,7 @@ static int random_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(s = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ s = ast_strdupa(data);
prob = strsep(&s,":");
if ((!prob) || (sscanf(prob, "%d", &probint) != 1))
diff --git a/apps/app_read.c b/apps/app_read.c
index fa1c01c92..5bd20be3a 100644
--- a/apps/app_read.c
+++ b/apps/app_read.c
@@ -115,10 +115,7 @@ static int read_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(argcopy = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ argcopy = ast_strdupa(data);
AST_STANDARD_APP_ARGS(arglist, argcopy);
diff --git a/apps/app_readfile.c b/apps/app_readfile.c
index f0c1215ae..5eedce2bf 100644
--- a/apps/app_readfile.c
+++ b/apps/app_readfile.c
@@ -70,10 +70,7 @@ static int readfile_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(s = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ s = ast_strdupa(data);
varname = strsep(&s, "=");
file = strsep(&s, "|");
diff --git a/apps/app_realtime.c b/apps/app_realtime.c
index 49aa31cc3..a1bd140a8 100644
--- a/apps/app_realtime.c
+++ b/apps/app_realtime.c
@@ -149,16 +149,15 @@ static int realtime_update_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if ((family = ast_strdupa(data))) {
- if ((colmatch = strchr(family,'|'))) {
- crop_data(colmatch);
- if ((value = strchr(colmatch,'|'))) {
- crop_data(value);
- if ((newcol = strchr(value,'|'))) {
- crop_data(newcol);
- if ((newval = strchr(newcol,'|')))
- crop_data(newval);
- }
+ family = ast_strdupa(data);
+ if ((colmatch = strchr(family,'|'))) {
+ crop_data(colmatch);
+ if ((value = strchr(colmatch,'|'))) {
+ crop_data(value);
+ if ((newcol = strchr(value,'|'))) {
+ crop_data(newcol);
+ if ((newval = strchr(newcol,'|')))
+ crop_data(newval);
}
}
}
@@ -196,14 +195,13 @@ static int realtime_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if ((family = ast_strdupa(data))) {
- if ((colmatch = strchr(family,'|'))) {
- crop_data(colmatch);
- if ((value = strchr(colmatch,'|'))) {
- crop_data(value);
- if ((prefix = strchr(value,'|')))
- crop_data(prefix);
- }
+ family = ast_strdupa(data);
+ if ((colmatch = strchr(family,'|'))) {
+ crop_data(colmatch);
+ if ((value = strchr(colmatch,'|'))) {
+ crop_data(value);
+ if ((prefix = strchr(value,'|')))
+ crop_data(prefix);
}
}
if (! (family && value && colmatch) ) {
diff --git a/apps/app_record.c b/apps/app_record.c
index 38d6437e7..3a2a0f37c 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -113,10 +113,7 @@ static int record_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
/* Yay for strsep being easy */
- if (!(vdata = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ vdata = ast_strdupa(data);
p = vdata;
filename = strsep(&p, "|");
diff --git a/apps/app_sayunixtime.c b/apps/app_sayunixtime.c
index 3cb797f45..86a1fb990 100644
--- a/apps/app_sayunixtime.c
+++ b/apps/app_sayunixtime.c
@@ -84,8 +84,7 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data)
if (!data)
return 0;
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
LOCAL_USER_ADD(u);
diff --git a/apps/app_senddtmf.c b/apps/app_senddtmf.c
index ece050f69..fba595e0a 100644
--- a/apps/app_senddtmf.c
+++ b/apps/app_senddtmf.c
@@ -73,10 +73,7 @@ static int senddtmf_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(digits = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ digits = ast_strdupa(data);
if ((to = strchr(digits,'|'))) {
*to = '\0';
diff --git a/apps/app_sendtext.c b/apps/app_sendtext.c
index 87f0f0bec..248c559bc 100644
--- a/apps/app_sendtext.c
+++ b/apps/app_sendtext.c
@@ -83,12 +83,8 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
LOCAL_USER_REMOVE(u);
return -1;
- } else {
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
- }
+ } else
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_setcallerid.c b/apps/app_setcallerid.c
index 5d34859fc..a92f35741 100644
--- a/apps/app_setcallerid.c
+++ b/apps/app_setcallerid.c
@@ -115,10 +115,7 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ tmp = ast_strdupa(data);
opt = strchr(tmp, '|');
if (opt) {
diff --git a/apps/app_skel.c b/apps/app_skel.c
index debe358d4..640d62422 100644
--- a/apps/app_skel.c
+++ b/apps/app_skel.c
@@ -95,10 +95,7 @@ static int app_exec(struct ast_channel *chan, void *data)
/* Do our thing here */
/* We need to make a copy of the input string if we are going to modify it! */
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 6404c1b6d..8b1194c39 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -327,8 +327,7 @@ static int speech_load(struct ast_channel *chan, void *data)
struct ast_speech *speech = find_speech(chan);
char *argv[2], *args = NULL, *name = NULL, *path = NULL;
- if (!(args = ast_strdupa(data)))
- return -1;
+ args = ast_strdupa(data);
LOCAL_USER_ADD(u);
@@ -504,8 +503,7 @@ static int speech_background(struct ast_channel *chan, void *data)
struct ast_datastore *datastore = NULL;
char *argv[2], *args = NULL, *filename = NULL, tmp[2] = "";
- if (!(args = ast_strdupa(data)))
- return -1;
+ args = ast_strdupa(data);
LOCAL_USER_ADD(u);
diff --git a/apps/app_stack.c b/apps/app_stack.c
index 1734f0311..4d21d0f8c 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -130,8 +130,7 @@ static int gosubif_exec(struct ast_channel *chan, void *data)
return 0;
}
- if (!(args = ast_strdupa(data)))
- return -1;
+ args = ast_strdupa(data);
LOCAL_USER_ADD(u);
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index dadde6a02..c08f929a0 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -86,10 +86,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ tmp = ast_strdupa(data);
stringp=tmp;
strsep(&stringp, "|");
diff --git a/apps/app_transfer.c b/apps/app_transfer.c
index 8bd046097..81d8f2cad 100644
--- a/apps/app_transfer.c
+++ b/apps/app_transfer.c
@@ -89,12 +89,8 @@ static int transfer_exec(struct ast_channel *chan, void *data)
LOCAL_USER_REMOVE(u);
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
return 0;
- } else {
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
- }
+ } else
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/apps/app_url.c b/apps/app_url.c
index 7d34d9d9b..c46d8f0db 100644
--- a/apps/app_url.c
+++ b/apps/app_url.c
@@ -92,10 +92,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(tmp = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ tmp = ast_strdupa(data);
stringp=tmp;
strsep(&stringp, "|");
diff --git a/apps/app_userevent.c b/apps/app_userevent.c
index c476c71fe..8d2586779 100644
--- a/apps/app_userevent.c
+++ b/apps/app_userevent.c
@@ -72,10 +72,7 @@ static int userevent_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(info = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ info = ast_strdupa(data);
snprintf(eventname, sizeof(eventname), "UserEvent%s", info);
eventbody = strchr(eventname, '|');
diff --git a/apps/app_verbose.c b/apps/app_verbose.c
index 02d49af62..e4ee8f068 100644
--- a/apps/app_verbose.c
+++ b/apps/app_verbose.c
@@ -65,34 +65,34 @@ static int verbose_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (data) {
- if ((vtext = ast_strdupa(data))) {
- char *tmp = strsep(&vtext, "|");
- if (vtext) {
- if (sscanf(tmp, "%d", &vsize) != 1) {
- vsize = 0;
- ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext);
- }
- } else {
- vtext = tmp;
+ char *tmp;
+ vtext = ast_strdupa(data);
+ tmp = strsep(&vtext, "|");
+ if (vtext) {
+ if (sscanf(tmp, "%d", &vsize) != 1) {
vsize = 0;
+ ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext);
}
- if (option_verbose >= vsize) {
- switch (vsize) {
- case 0:
- ast_verbose("%s\n", vtext);
- break;
- case 1:
- ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext);
- break;
- case 2:
- ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext);
- break;
- case 3:
- ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext);
- break;
- default:
- ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext);
- }
+ } else {
+ vtext = tmp;
+ vsize = 0;
+ }
+ if (option_verbose >= vsize) {
+ switch (vsize) {
+ case 0:
+ ast_verbose("%s\n", vtext);
+ break;
+ case 1:
+ ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext);
+ break;
+ case 2:
+ ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext);
+ break;
+ case 3:
+ ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext);
+ break;
+ default:
+ ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext);
}
}
}
@@ -115,10 +115,7 @@ static int log_exec(struct ast_channel *chan, void *data)
return 0;
}
- if (!(ltext = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return 0;
- }
+ ltext = ast_strdupa(data);
level = strsep(&ltext, "|");
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 9b3d2ad27..e718853dd 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3368,25 +3368,24 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu,
}
/* Attach only the first format */
- if ((fmt = ast_strdupa(fmt))) {
- stringp = fmt;
- strsep(&stringp, "|");
+ fmt = ast_strdupa(fmt);
+ stringp = fmt;
+ strsep(&stringp, "|");
- if (!ast_strlen_zero(vmu->email)) {
- int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
- char *myserveremail = serveremail;
- attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
- if (!ast_strlen_zero(vmu->serveremail))
- myserveremail = vmu->serveremail;
- sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category);
- }
+ if (!ast_strlen_zero(vmu->email)) {
+ int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
+ char *myserveremail = serveremail;
+ attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
+ if (!ast_strlen_zero(vmu->serveremail))
+ myserveremail = vmu->serveremail;
+ sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category);
+ }
- if (!ast_strlen_zero(vmu->pager)) {
- char *myserveremail = serveremail;
- if (!ast_strlen_zero(vmu->serveremail))
- myserveremail = vmu->serveremail;
- sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category);
- }
+ if (!ast_strlen_zero(vmu->pager)) {
+ char *myserveremail = serveremail;
+ if (!ast_strlen_zero(vmu->serveremail))
+ myserveremail = vmu->serveremail;
+ sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category);
}
if (ast_test_flag(vmu, VM_DELETE)) {
@@ -5356,10 +5355,7 @@ static int vm_execmain(struct ast_channel *chan, void *data)
AST_APP_ARG(argv1);
);
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -5826,12 +5822,7 @@ static int vm_exec(struct ast_channel *chan, void *data)
ast_answer(chan);
if (!ast_strlen_zero(data)) {
- tmp = ast_strdupa((char *)data);
- if (!tmp) {
- ast_log(LOG_ERROR, "Out of memory\n");
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
if (args.argc == 2) {
if (ast_app_parse_options(vm_app_options, &flags, opts, args.argv1)) {
@@ -5958,10 +5949,7 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(box = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ box = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, box);
@@ -5998,8 +5986,7 @@ static int vmauthenticate(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (s) {
- if (!(s = ast_strdupa(s)))
- return -1;
+ s = ast_strdupa(s);
user = strsep(&s, "|");
options = strsep(&s, "|");
if (user) {
@@ -6471,24 +6458,21 @@ static int load_config(void)
struct vm_zone *z;
if ((z = ast_malloc(sizeof(*z)))) {
char *msg_format, *timezone;
- if ((msg_format = ast_strdupa(var->value))) {
- timezone = strsep(&msg_format, "|");
- if (msg_format) {
- ast_copy_string(z->name, var->name, sizeof(z->name));
- ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
- ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
- AST_LIST_LOCK(&zones);
- AST_LIST_INSERT_HEAD(&zones, z, list);
- AST_LIST_UNLOCK(&zones);
- } else {
- ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
- free(z);
- }
+ msg_format = ast_strdupa(var->value);
+ timezone = strsep(&msg_format, "|");
+ if (msg_format) {
+ ast_copy_string(z->name, var->name, sizeof(z->name));
+ ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
+ ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
+ AST_LIST_LOCK(&zones);
+ AST_LIST_INSERT_HEAD(&zones, z, list);
+ AST_LIST_UNLOCK(&zones);
} else {
+ ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
free(z);
- return -1;
}
- } else {
+ } else {
+ free(z);
return -1;
}
var = var->next;
diff --git a/apps/app_while.c b/apps/app_while.c
index 754154e8d..04b0a5c8f 100644
--- a/apps/app_while.c
+++ b/apps/app_while.c
@@ -202,9 +202,8 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
snprintf(used_index, VAR_SIZE, "%d", used_index_i);
snprintf(new_index, VAR_SIZE, "%d", used_index_i + 1);
- if (!end) {
- condition = ast_strdupa((char *) data);
- }
+ if (!end)
+ condition = ast_strdupa(data);
size = strlen(chan->context) + strlen(chan->exten) + 32;
my_name = alloca(size);
diff --git a/apps/app_zapras.c b/apps/app_zapras.c
index d75d2ee7c..ce1e3828b 100644
--- a/apps/app_zapras.c
+++ b/apps/app_zapras.c
@@ -215,10 +215,7 @@ static int zapras_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
- if (!(args = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ args = ast_strdupa(data);
/* Answer the channel if it's not up */
if (chan->_state != AST_STATE_UP)
diff --git a/apps/app_zapscan.c b/apps/app_zapscan.c
index c8e0d75dd..17af23bb3 100644
--- a/apps/app_zapscan.c
+++ b/apps/app_zapscan.c
@@ -307,7 +307,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
if (chan->_state != AST_STATE_UP)
ast_answer(chan);
- desired_group = ast_strdupa((char *) data);
+ desired_group = ast_strdupa(data);
if(!ast_strlen_zero(desired_group)) {
ast_verbose(VERBOSE_PREFIX_3 "Scanning for group %s\n", desired_group);
search_group = 1;
diff --git a/callerid.c b/callerid.c
index 58891d0fa..b88392691 100644
--- a/callerid.c
+++ b/callerid.c
@@ -1029,11 +1029,6 @@ int ast_callerid_split(const char *buf, char *name, int namelen, char *num, int
char *l = NULL, *n = NULL;
tmp = ast_strdupa(buf);
- if (!tmp) {
- name[0] = '\0';
- num[0] = '\0';
- return -1;
- }
ast_callerid_parse(tmp, &n, &l);
if (n)
ast_copy_string(name, n, namelen);
diff --git a/channel.c b/channel.c
index 3b79f7c3c..e341ae30b 100644
--- a/channel.c
+++ b/channel.c
@@ -1597,11 +1597,8 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
} *fdmap;
sz = n * AST_MAX_FDS + nfds;
- if (!(pfds = alloca(sizeof(*pfds) * sz)) || !(fdmap = alloca(sizeof(*fdmap) * sz))) {
- ast_log(LOG_ERROR, "Out of memory\n");
- *outfd = -1;
- return NULL;
- }
+ pfds = alloca(sizeof(*pfds) * sz);
+ fdmap = alloca(sizeof(*fdmap) * sz);
if (outfd)
*outfd = -99999;
@@ -3773,8 +3770,6 @@ ast_group_t ast_get_group(char *s)
ast_group_t group = 0;
c = ast_strdupa(s);
- if (!c)
- return 0;
while ((piece = strsep(&c, ","))) {
if (sscanf(piece, "%d-%d", &start, &finish) == 2) {
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 8da8b5d9c..c62eaf6d3 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -294,8 +294,7 @@ static struct agent_pvt *add_agent(char *agent, int pending)
char *agt = NULL;
struct agent_pvt *p;
- if (!(parse = ast_strdupa(agent)))
- return NULL;
+ parse = ast_strdupa(agent);
/* Extract username (agt), password and name from agent (args). */
AST_NONSTANDARD_APP_ARGS(args, parse, ',');
@@ -1751,10 +1750,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
LOCAL_USER_ADD(u);
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
@@ -2486,8 +2482,7 @@ static int function_agent(struct ast_channel *chan, char *cmd, char *data, char
return -1;
}
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_NONSTANDARD_APP_ARGS(args, parse, ':');
if (!args.item)
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 862875185..5e69cc4cd 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -2969,12 +2969,10 @@ static int create_addr(const char *peername, struct sockaddr_in *sin, struct cre
char *key = NULL;
family = ast_strdupa(peer->dbsecret);
- if (family) {
- key = strchr(family, '/');
- if (key)
- *key++ = '\0';
- }
- if (!family || !key || ast_db_get(family, key, cai->secret, sizeof(cai->secret))) {
+ key = strchr(family, '/');
+ if (key)
+ *key++ = '\0';
+ if (!key || ast_db_get(family, key, cai->secret, sizeof(cai->secret))) {
ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", peer->dbsecret);
if (ast_test_flag(peer, IAX_TEMPONLY))
destroy_peer(peer);
@@ -4078,7 +4076,7 @@ static int decrypt_frame(int callno, struct ast_iax2_full_hdr *fh, struct ast_fr
tmppw = ast_strdupa(iaxs[callno]->secret);
stringp = tmppw;
- while((tmppw = strsep(&stringp, ";"))) {
+ while ((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)iaxs[callno]->challenge, strlen(iaxs[callno]->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@@ -5132,14 +5130,12 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
if (!ast_strlen_zero(user->dbsecret)) {
char *family, *key=NULL;
family = ast_strdupa(user->dbsecret);
- if (family) {
- key = strchr(family, '/');
- if (key) {
- *key = '\0';
- key++;
- }
+ key = strchr(family, '/');
+ if (key) {
+ *key = '\0';
+ key++;
}
- if (!family || !key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
+ if (!key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", user->dbsecret);
if (ast_test_flag(user, IAX_TEMPONLY)) {
destroy_user(user);
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 1573a0efb..1f0848a33 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2088,12 +2088,10 @@ static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
char *tmpcall;
char *c;
tmpcall = ast_strdupa(r->callid);
- if (tmpcall) {
- c = strchr(tmpcall, '@');
- if (c) {
- *c = '\0';
- ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
- }
+ c = strchr(tmpcall, '@');
+ if (c) {
+ *c = '\0';
+ ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
}
}
if (ast_strlen_zero(r->tohost)) {
@@ -6986,21 +6984,21 @@ static int get_refer_info(struct sip_pvt *sip_pvt, struct sip_request *outgoing_
if (!req)
req = &sip_pvt->initreq;
- if (!( (p_refer_to = get_header(req, "Refer-To")) && (h_refer_to = ast_strdupa(p_refer_to)) )) {
+ if (!(p_refer_to = get_header(req, "Refer-To"))) {
ast_log(LOG_WARNING, "No Refer-To Header That's illegal\n");
return -1;
}
-
+ h_refer_to = ast_strdupa(p_refer_to);
refer_to = get_in_brackets(h_refer_to);
- if (!( (p_referred_by = get_header(req, "Referred-By")) && (h_referred_by = ast_strdupa(p_referred_by)) )) {
- ast_log(LOG_WARNING, "No Referrred-By Header That's not illegal\n");
+ if (!(p_referred_by = get_header(req, "Referred-By"))) {
+ ast_log(LOG_DEBUG, "No Referrred-By Header That's not illegal\n");
return -1;
- } else {
- if (pedanticsipchecking)
- ast_uri_decode(h_referred_by);
- referred_by = get_in_brackets(h_referred_by);
}
+ h_referred_by = ast_strdupa(p_referred_by);
+ if (pedanticsipchecking)
+ ast_uri_decode(h_referred_by);
+ referred_by = get_in_brackets(h_referred_by);
h_contact = get_header(req, "Contact");
if (strncmp(refer_to, "sip:", 4)) {
@@ -7327,13 +7325,9 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
if ((c = strchr(of, ':')))
*c = '\0';
tmp = ast_strdupa(of);
- if (tmp) {
- if (ast_is_shrinkable_phonenumber(tmp))
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, of);
- }
+ if (ast_is_shrinkable_phonenumber(tmp))
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (ast_strlen_zero(of))
return 0;
@@ -7359,13 +7353,9 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
tmp = ast_strdupa(rpid_num);
- if (tmp) {
- if (ast_is_shrinkable_phonenumber(tmp))
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, rpid_num);
- }
+ if (ast_is_shrinkable_phonenumber(tmp))
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
@@ -7396,13 +7386,9 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
ast_string_field_set(p, context, user->context);
if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
char *tmp = ast_strdupa(user->cid_num);
- if (tmp) {
- if (ast_is_shrinkable_phonenumber(tmp))
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, user->cid_num);
- }
+ if (ast_is_shrinkable_phonenumber(tmp))
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (!ast_strlen_zero(user->cid_name) && !ast_strlen_zero(p->cid_num))
ast_string_field_set(p, cid_name, user->cid_name);
@@ -7473,13 +7459,9 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
char *tmp = ast_strdupa(rpid_num);
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
- if (tmp) {
- if (ast_is_shrinkable_phonenumber(tmp))
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, rpid_num);
- }
+ if (ast_is_shrinkable_phonenumber(tmp))
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
usenatroute = ast_test_flag(&p->flags[0], SIP_NAT_ROUTE);
if (p->rtp) {
@@ -7529,13 +7511,9 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
}
if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
char *tmp = ast_strdupa(peer->cid_num);
- if (tmp) {
- if (ast_is_shrinkable_phonenumber(tmp))
- ast_shrink_phone_number(tmp);
- ast_string_field_set(p, cid_num, tmp);
- } else {
- ast_string_field_set(p, cid_num, peer->cid_num);
- }
+ if (ast_is_shrinkable_phonenumber(tmp))
+ ast_shrink_phone_number(tmp);
+ ast_string_field_set(p, cid_num, tmp);
}
if (!ast_strlen_zero(peer->cid_name) && !ast_strlen_zero(p->cid_name))
ast_string_field_set(p, cid_name, peer->cid_name);
@@ -12740,7 +12718,7 @@ static struct sip_user *build_user(const char *name, struct ast_variable *v, int
ast_copy_string(user->subscribecontext, v->value, sizeof(user->subscribecontext));
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
- if (varname && (varval = strchr(varname,'='))) {
+ if ((varval = strchr(varname,'='))) {
*varval++ = '\0';
if ((tmpvar = ast_variable_new(varname, varval))) {
tmpvar->next = user->chanvars;
@@ -13054,7 +13032,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
} else if (!strcasecmp(v->name, "setvar")) {
/* Set peer channel variable */
varname = ast_strdupa(v->value);
- if (varname && (varval = strchr(varname,'='))) {
+ if ((varval = strchr(varname, '='))) {
*varval++ = '\0';
if ((tmpvar = ast_variable_new(varname, varval))) {
tmpvar->next = peer->chanvars;
@@ -13746,8 +13724,7 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest)
char *extension, *host, *port;
char tmp[80];
- if (!(cdest = ast_strdupa(dest)))
- return 0;
+ cdest = ast_strdupa(dest);
extension = strsep(&cdest, "@");
host = strsep(&cdest, ":");
@@ -13776,11 +13753,9 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest)
ast_log(LOG_ERROR, "Can't find the host address\n");
return 0;
}
- if (!(host = ast_strdupa(lhost)))
- return 0;
+ host = ast_strdupa(lhost);
if (!ast_strlen_zero(lport)) {
- if (!(port = ast_strdupa(lport)))
- return 0;
+ port = ast_strdupa(lport);
}
}
}
diff --git a/dsp.c b/dsp.c
index a11f272c8..9adddaad1 100644
--- a/dsp.c
+++ b/dsp.c
@@ -1444,19 +1444,13 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
len = af->datalen / 2;
break;
case AST_FORMAT_ULAW:
- if (!(shortdata = alloca(af->datalen * 2))) {
- ast_log(LOG_WARNING, "Unable to allocate stack space for data: %s\n", strerror(errno));
- return af;
- }
- for (x=0;x<len;x++)
+ shortdata = alloca(af->datalen * 2);
+ for (x = 0;x < len; x++)
shortdata[x] = AST_MULAW(odata[x]);
break;
case AST_FORMAT_ALAW:
- if (!(shortdata = alloca(af->datalen * 2))) {
- ast_log(LOG_WARNING, "Unable to allocate stack space for data: %s\n", strerror(errno));
- return af;
- }
- for (x=0;x<len;x++)
+ shortdata = alloca(af->datalen * 2);
+ for (x = 0; x < len; x++)
shortdata[x] = AST_ALAW(odata[x]);
break;
default:
diff --git a/funcs/func_cut.c b/funcs/func_cut.c
index a4bce49c1..4d3a85f3d 100644
--- a/funcs/func_cut.c
+++ b/funcs/func_cut.c
@@ -78,8 +78,7 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
if (!data)
return ERROR_NOARG;
- if (!(strings = ast_strdupa(data)))
- return ERROR_NOMEM;
+ strings = ast_strdupa(data);
for (ptrkey = strings; *ptrkey; ptrkey++) {
if (*ptrkey == '|')
@@ -87,8 +86,6 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
}
sortable_keys = alloca(count * sizeof(struct sortable_keys));
- if (!sortable_keys)
- return ERROR_NOMEM;
memset(sortable_keys, 0, count * sizeof(struct sortable_keys));
@@ -132,8 +129,7 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
memset(buffer, 0, buflen);
- if (!(parse = ast_strdupa(data)))
- return ERROR_NOMEM;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index 134caa8dc..4f563be54 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -437,12 +437,7 @@ char * __attribute__((malloc)) _ast_strndup(const char *str, size_t len, const c
const char *__old = (s); \
size_t __len = strlen(__old) + 1; \
char *__new = __builtin_alloca(__len); \
- if (__builtin_expect(!__new, 0)) \
- ast_log(LOG_ERROR, "Stack Allocation Error in" \
- "function '%s' at line '%d' of '%s'!\n", \
- __PRETTY_FUNCTION__, __LINE__, __FILE__); \
- else \
- memcpy (__new, __old, __len); \
+ memcpy (__new, __old, __len); \
__new; \
}))
#endif
diff --git a/indications.c b/indications.c
index 93cc6c25c..7dc1a05bb 100644
--- a/indications.c
+++ b/indications.c
@@ -213,10 +213,9 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst,
{
char *s, *data = ast_strdupa(playlst); /* cute */
struct playtones_def d = { vol, -1, 0, 1, NULL};
- char *stringp=NULL;
+ char *stringp;
char *separator;
- if (!data)
- return -1;
+
if (vol < 1)
d.vol = 7219; /* Default to -8db */
diff --git a/loader.c b/loader.c
index dd3e1afe8..c09673d69 100644
--- a/loader.c
+++ b/loader.c
@@ -647,8 +647,7 @@ static void *find_symbol(struct module *m, const char *name, int verbose)
if (name[0] == '_')
name++;
- if (!(n1 = alloca(strlen(name) + 2))) /* room for leading '_' and final '\0' */
- return NULL;
+ n1 = alloca(strlen(name) + 2); /* room for leading '_' and final '\0' */
n1[0] = '_';
strcpy(n1+1, name);
s = dlsym(m->lib, n1+1); /* try without '_' */
diff --git a/logger.c b/logger.c
index ff3513634..522a96b2d 100644
--- a/logger.c
+++ b/logger.c
@@ -861,10 +861,7 @@ void ast_verbose(const char *fmt, ...)
time(&t);
localtime_r(&t, &tm);
strftime(date, sizeof(date), dateformat, &tm);
- if ((datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1))) {
- sprintf(datefmt, "[%s] %s", date, fmt);
- fmt = datefmt;
- }
+ datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
}
/* this lock is also protecting against multiple threads
diff --git a/manager.c b/manager.c
index db61e28e5..d096c0689 100644
--- a/manager.c
+++ b/manager.c
@@ -588,8 +588,7 @@ struct ast_variable *astman_get_variables(struct message *m)
if (strncasecmp("Variable: ", m->headers[x], varlen))
continue;
- if (!(parse = ast_strdupa(m->headers[x] + varlen)))
- return head;
+ parse = ast_strdupa(m->headers[x] + varlen);
AST_STANDARD_APP_ARGS(args, parse);
if (args.argc) {
diff --git a/netsock.c b/netsock.c
index a7799e967..7c77e9315 100644
--- a/netsock.c
+++ b/netsock.c
@@ -186,10 +186,6 @@ struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_co
sin.sin_family = AF_INET;
sin.sin_port = htons(defaultport);
tmp = ast_strdupa(bindinfo);
- if (!tmp) {
- ast_log(LOG_WARNING, "Out of memory!\n");
- return NULL;
- }
host = strsep(&tmp, ":");
port = tmp;
diff --git a/pbx.c b/pbx.c
index 24aa3febd..a29178af3 100644
--- a/pbx.c
+++ b/pbx.c
@@ -4989,8 +4989,7 @@ static int pbx_builtin_resetcdr(struct ast_channel *chan, void *data)
struct ast_flags flags = { 0 };
if (!ast_strlen_zero(data)) {
- if (!(args = ast_strdupa(data)))
- return -1;
+ args = ast_strdupa(data);
ast_app_parse_options(resetcdr_opts, &flags, NULL, args);
}
@@ -5034,16 +5033,15 @@ static int pbx_builtin_gotoiftime(struct ast_channel *chan, void *data)
return -1;
}
- if ((s = ast_strdupa(data))) {
- ts = s;
+ ts = s = ast_strdupa(data);
- /* Separate the Goto path */
- strsep(&ts,"?");
+ /* Separate the Goto path */
+ strsep(&ts,"?");
- /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
- if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
- res = pbx_builtin_goto(chan, (void *)ts);
- }
+ /* struct ast_include include contained garbage here, fixed by zeroing it on get_timerange */
+ if (ast_build_timing(&timing, s) && ast_check_timing(&timing))
+ res = pbx_builtin_goto(chan, ts);
+
return res;
}
@@ -5062,8 +5060,7 @@ static int pbx_builtin_execiftime(struct ast_channel *chan, void *data)
return -1;
}
- if (!(appname = ast_strdupa(data)))
- return -1;
+ appname = ast_strdupa(data);
s = strsep(&appname,"?"); /* Separate the timerange and application name/data */
if (!appname) { /* missing application */
@@ -5121,8 +5118,7 @@ static int pbx_builtin_waitexten(struct ast_channel *chan, void *data)
);
if (!ast_strlen_zero(data)) {
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
} else
memset(&args, 0, sizeof(args));
@@ -5179,8 +5175,7 @@ static int pbx_builtin_background(struct ast_channel *chan, void *data)
if (ast_strlen_zero(data))
ast_log(LOG_WARNING, "Background requires an argument (filename)\n");
- if (!(parse = ast_strdupa(data)))
- return -1;
+ parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index fedbd199d..f8f9e326f 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -3875,8 +3875,7 @@ static void build_mapping(char *name, char *value)
int x;
int y;
- if (!(t = ast_strdupa(value)))
- return;
+ t = ast_strdupa(value);
AST_LIST_TRAVERSE(&mappings, map, list) {
/* Find a double match */
diff --git a/res/res_agi.c b/res/res_agi.c
index c4df2421e..d1218e288 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -138,8 +138,6 @@ static int launch_netscript(char *agiurl, char *argv[], int *fds, int *efd, int
/* agiusl is "agi://host.domain[:port][/script/name]" */
host = ast_strdupa(agiurl + 6); /* Remove agi:// */
- if (!host)
- return -1;
/* Strip off any script name */
if ((c = strchr(host, '/'))) {
*c = '\0';
diff --git a/res/res_clioriginate.c b/res/res_clioriginate.c
index 1c02491d2..306975946 100644
--- a/res/res_clioriginate.c
+++ b/res/res_clioriginate.c
@@ -76,8 +76,7 @@ static int orig_app(int fd, const char *chan, const char *app, const char *appda
if (ast_strlen_zero(app))
return RESULT_SHOWUSAGE;
- if (!(chandata = ast_strdupa(chan)))
- return RESULT_FAILURE;
+ chandata = ast_strdupa(chan);
chantech = strsep(&chandata, "/");
if (!chandata) {
@@ -98,8 +97,7 @@ static int orig_exten(int fd, const char *chan, const char *data)
char *context = NULL;
int reason = 0;
- if (!(chandata = ast_strdupa(chan)))
- return RESULT_FAILURE;
+ chandata = ast_strdupa(chan);
chantech = strsep(&chandata, "/");
if (!chandata) {
@@ -108,8 +106,7 @@ static int orig_exten(int fd, const char *chan, const char *data)
}
if (!ast_strlen_zero(data)) {
- if (!(context = ast_strdupa(data)))
- return RESULT_FAILURE;
+ context = ast_strdupa(data);
exten = strsep(&context, "@");
}
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 31a2d1513..0929f741c 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -252,7 +252,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
return NULL;
}
initfield = ast_strdupa(newparam);
- if (initfield && (op = strchr(initfield, ' ')))
+ if ((op = strchr(initfield, ' ')))
*op = '\0';
newval = va_arg(aq, const char *);
if (!strchr(newparam, ' ')) op = " ="; else op = "";
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 97d493456..2e900d00d 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -239,7 +239,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
}
initfield = ast_strdupa(newparam);
- if (initfield && (op = strchr(initfield, ' '))) {
+ if ((op = strchr(initfield, ' '))) {
*op = '\0';
}
diff --git a/res/res_convert.c b/res/res_convert.c
index 553075874..85bc7d2da 100644
--- a/res/res_convert.c
+++ b/res/res_convert.c
@@ -72,8 +72,8 @@ static int cli_audio_convert(int fd, int argc, char *argv[])
goto fail_out;
}
- if (!(file_in = ast_strdupa(argv[1])) || !(file_out = ast_strdupa(argv[2])))
- goto fail_out;
+ file_in = ast_strdupa(argv[1]);
+ file_out = ast_strdupa(argv[2]);
if (split_ext(file_in, &name_in, &ext_in)) {
ast_cli(fd, "'%s' is an invalid filename!\n", argv[1]);
diff --git a/res/res_features.c b/res/res_features.c
index b8c1cfe5b..c5dfbcfa6 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -174,26 +174,33 @@ static void check_goto_on_transfer(struct ast_channel *chan)
char *x, *goto_on_transfer;
struct ast_frame *f;
- if (!ast_strlen_zero(val) && (goto_on_transfer = ast_strdupa(val)) && (xferchan = ast_channel_alloc(0))) {
- for (x = goto_on_transfer; x && *x; x++)
- if (*x == '^')
- *x = '|';
- ast_string_field_set(xferchan, name, chan->name);
- /* Make formats okay */
- xferchan->readformat = chan->readformat;
- xferchan->writeformat = chan->writeformat;
- ast_channel_masquerade(xferchan, chan);
- ast_parseable_goto(xferchan, goto_on_transfer);
- xferchan->_state = AST_STATE_UP;
- ast_clear_flag(xferchan, AST_FLAGS_ALL);
- xferchan->_softhangup = 0;
- if ((f = ast_read(xferchan))) {
- ast_frfree(f);
- f = NULL;
- ast_pbx_start(xferchan);
- } else {
- ast_hangup(xferchan);
- }
+ if (ast_strlen_zero(val))
+ return;
+
+ goto_on_transfer = ast_strdupa(val);
+
+ if (!(xferchan = ast_channel_alloc(0)))
+ return;
+
+ for (x = goto_on_transfer; x && *x; x++) {
+ if (*x == '^')
+ *x = '|';
+ }
+ ast_string_field_set(xferchan, name, chan->name);
+ /* Make formats okay */
+ xferchan->readformat = chan->readformat;
+ xferchan->writeformat = chan->writeformat;
+ ast_channel_masquerade(xferchan, chan);
+ ast_parseable_goto(xferchan, goto_on_transfer);
+ xferchan->_state = AST_STATE_UP;
+ ast_clear_flag(xferchan, AST_FLAGS_ALL);
+ xferchan->_softhangup = 0;
+ if ((f = ast_read(xferchan))) {
+ ast_frfree(f);
+ f = NULL;
+ ast_pbx_start(xferchan);
+ } else {
+ ast_hangup(xferchan);
}
}
@@ -920,9 +927,6 @@ static int ast_feature_interpret(struct ast_channel *chan, struct ast_channel *p
char *tmp = ast_strdupa(dynamic_features);
char *tok;
- if (!tmp)
- return res;
-
while ((tok = strsep(&tmp, "#")) != NULL) {
feature = find_feature(tok);
@@ -966,11 +970,8 @@ static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer,
char *tok;
struct ast_call_feature *feature;
- if (!tmp) /* no memory */
- return;
-
/* while we have a feature */
- while (NULL != (tok = strsep(&tmp, "#"))) {
+ while ((tok = strsep(&tmp, "#"))) {
if ((feature = find_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
@@ -1191,11 +1192,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
src = peer;
if (monitor_app && src) {
char *tmp = ast_strdupa(monitor_exec);
- if (tmp) {
- pbx_exec(src, monitor_app, tmp);
- } else {
- ast_log(LOG_ERROR, "Monitor failed: out of memory\n");
- }
+ pbx_exec(src, monitor_app, tmp);
}
}
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 4f47a6512..23b2ed5ba 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -172,17 +172,13 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
seq++;
ast_mutex_unlock(&monitorlock);
- if((channel_name = ast_strdupa(chan->name))) {
- while((p = strchr(channel_name, '/'))) {
- *p = '-';
- }
- snprintf(monitor->filename_base, FILENAME_MAX, "%s/%d-%s",
- ast_config_AST_MONITOR_DIR, (int)time(NULL),channel_name);
- monitor->filename_changed = 1;
- } else {
- ast_log(LOG_ERROR,"Failed to allocate Memory\n");
- return -1;
+ channel_name = ast_strdupa(chan->name);
+ while ((p = strchr(channel_name, '/'))) {
+ *p = '-';
}
+ snprintf(monitor->filename_base, FILENAME_MAX, "%s/%d-%s",
+ ast_config_AST_MONITOR_DIR, (int)time(NULL), channel_name);
+ monitor->filename_changed = 1;
}
monitor->stop = ast_monitor_stop;
@@ -416,15 +412,13 @@ static int start_monitor_exec(struct ast_channel *chan, void *data)
the following could give NULL results, but we check just to
be pedantic. Reconstructing with checks for 'm' option does not
work if we end up adding more options than 'm' in the future. */
- delay = ast_strdupa((char*)data);
- if (delay) {
- options = strrchr(delay, '|');
- if (options) {
- arg = strchr(options, 'b');
- if (arg) {
- *arg = 'X';
- pbx_builtin_setvar_helper(chan,"AUTO_MONITOR",delay);
- }
+ delay = ast_strdupa(data);
+ options = strrchr(delay, '|');
+ if (options) {
+ arg = strchr(options, 'b');
+ if (arg) {
+ *arg = 'X';
+ pbx_builtin_setvar_helper(chan,"AUTO_MONITOR",delay);
}
}
return 0;
diff --git a/strcompat.c b/strcompat.c
index a5502c25e..9e275881c 100644
--- a/strcompat.c
+++ b/strcompat.c
@@ -60,8 +60,7 @@ int setenv(const char *name, const char *value, int overwrite)
int buflen;
buflen = strlen(name) + strlen(value) + 2;
- if (!(buf = alloca(buflen)))
- return -1;
+ buf = alloca(buflen);
if (!overwrite && getenv(name))
return 0;