From 4003b31fc53e01a948ee4ff59361a40f139fdd2e Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Wed, 18 Jul 2007 13:59:01 +0000 Subject: [PATCH] Minor code tweaks. Variables were being checked wrong in some situations and didn't need to be checked in others. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@75566 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 15 ++++++--------- channels/chan_agent.c | 4 ++-- channels/chan_sip.c | 2 +- pbx/pbx_realtime.c | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 96461fce9a..b5897df554 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -619,9 +619,9 @@ static struct ast_flags globalflags = {0}; static int saydurationminfo; -static char dialcontext[AST_MAX_CONTEXT]; -static char callcontext[AST_MAX_CONTEXT]; -static char exitcontext[AST_MAX_CONTEXT]; +static char dialcontext[AST_MAX_CONTEXT] = ""; +static char callcontext[AST_MAX_CONTEXT] = ""; +static char exitcontext[AST_MAX_CONTEXT] = ""; static char cidinternalcontexts[MAX_NUM_CID_CONTEXTS][64]; @@ -665,12 +665,9 @@ static void populate_defaults(struct ast_vm_user *vmu) ast_copy_flags(vmu, (&globalflags), AST_FLAGS_ALL); if (saydurationminfo) vmu->saydurationm = saydurationminfo; - if (callcontext) - ast_copy_string(vmu->callback, callcontext, sizeof(vmu->callback)); - if (dialcontext) - ast_copy_string(vmu->dialout, dialcontext, sizeof(vmu->dialout)); - if (exitcontext) - ast_copy_string(vmu->exit, exitcontext, sizeof(vmu->exit)); + ast_copy_string(vmu->callback, callcontext, sizeof(vmu->callback)); + ast_copy_string(vmu->dialout, dialcontext, sizeof(vmu->dialout)); + ast_copy_string(vmu->exit, exitcontext, sizeof(vmu->exit)); if (vmmaxsecs) vmu->maxsecs = vmmaxsecs; if (maxmsg) diff --git a/channels/chan_agent.c b/channels/chan_agent.c index cda841fa51..d1231556e8 100644 --- a/channels/chan_agent.c +++ b/channels/chan_agent.c @@ -390,10 +390,10 @@ static int __agent_start_monitoring(struct ast_channel *ast, struct agent_pvt *p /* substitute . for - */ if ((pointer = strchr(filename, '.'))) *pointer = '-'; - snprintf(tmp, sizeof(tmp), "%s%s",savecallsin ? savecallsin : "", filename); + snprintf(tmp, sizeof(tmp), "%s%s", savecallsin, filename); ast_monitor_start(ast, recordformat, tmp, needlock, X_REC_IN | X_REC_OUT); ast_monitor_setjoinfiles(ast, 1); - snprintf(tmp2, sizeof(tmp2), "%s%s.%s", urlprefix ? urlprefix : "", filename, recordformatext); + snprintf(tmp2, sizeof(tmp2), "%s%s.%s", urlprefix, filename, recordformatext); #if 0 ast_verbose("name is %s, link is %s\n",tmp, tmp2); #endif diff --git a/channels/chan_sip.c b/channels/chan_sip.c index b22d798ff4..2f5c5c5c2f 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -4948,7 +4948,7 @@ static int sip_register(char *value, int lineno) regobjs++; ASTOBJ_INIT(reg); ast_string_field_set(reg, callback, callback); - if (username) + if (!ast_strlen_zero(username)) ast_string_field_set(reg, username, username); if (hostname) ast_string_field_set(reg, hostname, hostname); diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c index 9ee770c99a..d1011fe8eb 100644 --- a/pbx/pbx_realtime.c +++ b/pbx/pbx_realtime.c @@ -211,7 +211,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch "Application: %s\r\n" "AppData: %s\r\n" "Uniqueid: %s\r\n", - chan->name, chan->context, chan->exten, chan->priority, app, appdata ? appdata : "(NULL)", chan->uniqueid); + chan->name, chan->context, chan->exten, chan->priority, app, !ast_strlen_zero(appdata) ? appdata : "(NULL)", chan->uniqueid); res = pbx_exec(chan, a, appdata); } else