remove almost all of the checks of the result from ast_strdupa() or alloca().
authorRussell Bryant <russell@russellbryant.com>
Wed, 10 May 2006 13:22:15 +0000 (13:22 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 10 May 2006 13:22:15 +0000 (13:22 +0000)
As it turns out, all of these checks were useless, because alloca will never
return NULL.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@26451 65c4cc65-6c06-0410-ace0-fbb531ad65f3

63 files changed:
app.c
apps/app_amd.c
apps/app_authenticate.c
apps/app_db.c
apps/app_dial.c
apps/app_dictate.c
apps/app_directory.c
apps/app_disa.c
apps/app_exec.c
apps/app_externalivr.c
apps/app_festival.c
apps/app_hasnewvoicemail.c
apps/app_image.c
apps/app_mixmonitor.c
apps/app_osplookup.c
apps/app_page.c
apps/app_playback.c
apps/app_privacy.c
apps/app_queue.c
apps/app_random.c
apps/app_read.c
apps/app_readfile.c
apps/app_realtime.c
apps/app_record.c
apps/app_sayunixtime.c
apps/app_senddtmf.c
apps/app_sendtext.c
apps/app_setcallerid.c
apps/app_skel.c
apps/app_speech_utils.c
apps/app_stack.c
apps/app_talkdetect.c
apps/app_transfer.c
apps/app_url.c
apps/app_userevent.c
apps/app_verbose.c
apps/app_voicemail.c
apps/app_while.c
apps/app_zapras.c
apps/app_zapscan.c
callerid.c
channel.c
channels/chan_agent.c
channels/chan_iax2.c
channels/chan_sip.c
dsp.c
funcs/func_cut.c
include/asterisk/utils.h
indications.c
loader.c
logger.c
manager.c
netsock.c
pbx.c
pbx/pbx_dundi.c
res/res_agi.c
res/res_clioriginate.c
res/res_config_odbc.c
res/res_config_pgsql.c
res/res_convert.c
res/res_features.c
res/res_monitor.c
strcompat.c

diff --git a/app.c b/app.c
index afc6213..dcd4d6d 100644 (file)
--- 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);
index 16fc6bf..b79f823 100644 (file)
@@ -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);
 
index eb3b718..bb67fb1 100644 (file)
@@ -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);
        
index bb4bcbd..4c5f5c6 100644 (file)
@@ -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, "/");
index 7d97187..b3fe1c0 100644 (file)
@@ -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));
 
index 95f8140..769121d 100644 (file)
@@ -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;
index d5851d9..0dc7dc1 100644 (file)
@@ -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);
                
index d7c3a58..b49fe47 100644 (file)
@@ -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);
 
index d41bf27..e9564b1 100644 (file)
@@ -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';
index 7a9757e..ecc8bf8 100644 (file)
@@ -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]));
 
index cb38d42..5a4bb05 100644 (file)
@@ -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) {   
index f21bd7a..2bc730e 100644 (file)
@@ -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);
 
index 9e69bd4..51389a6 100644 (file)
@@ -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);
 
index 7b16d48..324c3a3 100644 (file)
@@ -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);
        
index 7c09fee..6497983 100644 (file)
@@ -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);
 
index 7184ab9..cbc9b23 100644 (file)
@@ -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, '-')))
index 2816d53..abf9cd6 100644 (file)
@@ -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);
index 00af9fc..c1a0ea8 100644 (file)
@@ -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);
 
index 25329a9..c19b187 100644 (file)
@@ -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);
index 9809a53..9b9fac8 100644 (file)
@@ -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))
index fa1c01c..5bd20be 100644 (file)
@@ -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);
 
index f0c1215..5eedce2 100644 (file)
@@ -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, "|");
index 49aa31c..a1bd140 100644 (file)
@@ -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) ) {
index 38d6437..3a2a0f3 100644 (file)
@@ -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, "|");
index 3cb797f..86a1fb9 100644 (file)
@@ -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);
 
index ece050f..fba595e 100644 (file)
@@ -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';
index 87f0f0b..248c559 100644 (file)
@@ -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);
 
index 5d34859..a92f357 100644 (file)
@@ -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) {
index debe358..640d624 100644 (file)
@@ -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);
 
index 6404c1b..8b1194c 100644 (file)
@@ -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);
 
index 1734f03..4d21d0f 100644 (file)
@@ -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);
 
index dadde6a..c08f929 100644 (file)
@@ -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, "|");
index 8bd0460..81d8f2c 100644 (file)
@@ -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);
 
index 7d34d9d..c46d8f0 100644 (file)
@@ -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, "|");
index c476c71..8d25867 100644 (file)
@@ -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, '|');
index 02d49af..e4ee8f0 100644 (file)
@@ -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, "|");
 
index 9b3d2ad..e718853 100644 (file)
@@ -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;
index 754154e..04b0a5c 100644 (file)
@@ -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);
index d75d2ee..ce1e382 100644 (file)
@@ -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)
index c8e0d75..17af23b 100644 (file)
@@ -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;
index 58891d0..b883926 100644 (file)
@@ -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);
index 3b79f7c..e341ae3 100644 (file)
--- 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) {
index 8da8b5d..c62eaf6 100644 (file)
@@ -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)
index 8628751..5e69cc4 100644 (file)
@@ -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);
index 1573a0e..1f0848a 100644 (file)
@@ -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 a11f272..9adddaa 100644 (file)
--- 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:
index a4bce49..4d3a85f 100644 (file)
@@ -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);
 
index 134caa8..4f563be 100644 (file)
@@ -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
index 93cc6c2..7dc1a05 100644 (file)
@@ -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 */
 
index dd3e1af..c09673d 100644 (file)
--- 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 '_' */
index ff35136..522a96b 100644 (file)
--- 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
index db61e28..d096c06 100644 (file)
--- 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) {
index a7799e9..7c77e93 100644 (file)
--- 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 24aa3fe..a29178a 100644 (file)
--- 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);
 
index fedbd19..f8f9e32 100644 (file)
@@ -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 */
index c4df242..d1218e2 100644 (file)
@@ -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';
index 1c02491..3069759 100644 (file)
@@ -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, "@");
        }
 
index 31a2d15..0929f74 100644 (file)
@@ -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 = "";
index 97d4934..2e900d0 100644 (file)
@@ -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';
        }
 
index 5530758..85bc7d2 100644 (file)
@@ -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]);
index b8c1cfe..c5dfbcf 100644 (file)
@@ -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);
                }
        }
        
index 4f47a65..23b2ed5 100644 (file)
@@ -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;
index a5502c2..9e27588 100644 (file)
@@ -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;