diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-10 13:22:15 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-10 13:22:15 +0000 |
commit | d99b677f3501944b7aaf82375ef62a88e5fa3933 (patch) | |
tree | 167bf7a9b6b330883dc9bf865672132658710ffd /apps/app_exec.c | |
parent | a6b2177d50659d049694ca79f6cbe00f54dd0a93 (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
Diffstat (limited to 'apps/app_exec.c')
-rw-r--r-- | apps/app_exec.c | 78 |
1 files changed, 34 insertions, 44 deletions
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'; |