mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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: https://origsvn.digium.com/svn/asterisk/trunk@26451 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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';
|
||||
|
@@ -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, "@");
|
||||
}
|
||||
|
||||
|
@@ -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 = "";
|
||||
|
@@ -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';
|
||||
}
|
||||
|
||||
|
@@ -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]);
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user