From d99b677f3501944b7aaf82375ef62a88e5fa3933 Mon Sep 17 00:00:00 2001 From: russell Date: Wed, 10 May 2006 13:22:15 +0000 Subject: 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 --- apps/app_amd.c | 7 +--- apps/app_authenticate.c | 5 +-- apps/app_db.c | 10 ++---- apps/app_dial.c | 6 ++-- apps/app_dictate.c | 3 +- apps/app_directory.c | 5 +-- apps/app_disa.c | 5 +-- apps/app_exec.c | 78 ++++++++++++++++++++------------------------ apps/app_externalivr.c | 5 +-- apps/app_festival.c | 6 +--- apps/app_hasnewvoicemail.c | 5 +-- apps/app_image.c | 5 +-- apps/app_mixmonitor.c | 5 +-- apps/app_osplookup.c | 24 +++----------- apps/app_page.c | 5 +-- apps/app_playback.c | 5 +-- apps/app_privacy.c | 5 +-- apps/app_queue.c | 16 +++------- apps/app_random.c | 5 +-- apps/app_read.c | 5 +-- apps/app_readfile.c | 5 +-- apps/app_realtime.c | 34 ++++++++++---------- apps/app_record.c | 5 +-- apps/app_sayunixtime.c | 3 +- apps/app_senddtmf.c | 5 +-- apps/app_sendtext.c | 8 ++--- apps/app_setcallerid.c | 5 +-- apps/app_skel.c | 5 +-- apps/app_speech_utils.c | 6 ++-- apps/app_stack.c | 3 +- apps/app_talkdetect.c | 5 +-- apps/app_transfer.c | 8 ++--- apps/app_url.c | 5 +-- apps/app_userevent.c | 5 +-- apps/app_verbose.c | 57 ++++++++++++++++----------------- apps/app_voicemail.c | 80 +++++++++++++++++++--------------------------- apps/app_while.c | 5 ++- apps/app_zapras.c | 5 +-- apps/app_zapscan.c | 2 +- 39 files changed, 156 insertions(+), 305 deletions(-) (limited to 'apps') 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(<ext, "|"); 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; -- cgit v1.2.3