From: Kevin P. Fleming Date: Wed, 17 Jan 2007 01:29:12 +0000 (+0000) Subject: a few more coding style cleanups and one bug fix (from AnthonyL) X-Git-Tag: 1.4.1~267 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=439034e46445f5937c3b9f311f9116e2e9a992ca;p=thirdparty%2Fasterisk.git a few more coding style cleanups and one bug fix (from AnthonyL) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@51176 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 2b55ad840d..bb4514f81e 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -657,12 +657,11 @@ static void apply_options_full(struct ast_vm_user *retval, struct ast_variable * struct ast_variable *tmp; tmp = var; while (tmp) { - if (!strcasecmp(tmp->name, "password") || !strcasecmp(tmp->name, "secret")) { + if (!strcasecmp(tmp->name, "vmpassword")) { ast_copy_string(retval->password, tmp->value, sizeof(retval->password)); - } else if (!strcasecmp(tmp->name, "secret")) { - /* dont let secret override vmpassword */ + } else if (!strcasecmp(tmp->name, "secret")) { /* don't overwrite vmpassword if it exists */ if (ast_strlen_zero(retval->password)) - ast_copy_string(retval->password, tmp->value, sizeof(retval->password)); + ast_copy_string(retval->password, tmp->value, sizeof(retval->password)); } else if (!strcasecmp(tmp->name, "uniqueid")) { ast_copy_string(retval->uniqueid, tmp->value, sizeof(retval->uniqueid)); } else if (!strcasecmp(tmp->name, "pager")) { @@ -768,7 +767,6 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) struct ast_category *cat=NULL; char *category=NULL, *value=NULL, *new=NULL; const char *tmp=NULL; - int len; if (!change_password_realtime(vmu, newpassword)) return; @@ -787,14 +785,8 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) ast_log(LOG_WARNING, "variable has bad format.\n"); break; } - len = (strlen(value) + strlen(newpassword)); - - if (!(new = ast_calloc(1,len))) { - ast_log(LOG_WARNING, "Memory Allocation Failed.\n"); - break; - } + new = alloca((strlen(value)+strlen(newpassword)+1)); sprintf(new,"%s%s", newpassword, value); - if (!(cat = ast_category_get(cfg, category))) { ast_log(LOG_WARNING, "Failed to get category structure.\n"); break; @@ -806,8 +798,6 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) reset_user_pw(vmu->context, vmu->mailbox, newpassword); ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); config_text_file_save(VOICEMAIL_CONFIG, cfg, "AppVoicemail"); - if (new) - free(new); } category = NULL; var = NULL; @@ -825,15 +815,12 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) ast_log(LOG_DEBUG, "looks like we need to make vmpassword!\n"); var = ast_variable_new("vmpassword", newpassword); } - if (!(new = ast_calloc(1,strlen(newpassword)))) { - if (option_debug > 3) - ast_log(LOG_DEBUG, "Memory Allocation Failed.\n"); - break; - } + new = alloca(strlen(newpassword)+1); sprintf(new, "%s", newpassword); if (!(cat = ast_category_get(cfg, category))) { if (option_debug > 3) ast_log(LOG_DEBUG, "failed to get category!\n"); + break; } if (!var) ast_variable_update(cat, "vmpassword", new, NULL); @@ -845,10 +832,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) reset_user_pw(vmu->context, vmu->mailbox, newpassword); ast_copy_string(vmu->password, newpassword, sizeof(vmu->password)); config_text_file_save("users.conf", cfg, "AppVoicemail"); - if (new) - free(new); } - } static void vm_change_password_shell(struct ast_vm_user *vmu, char *newpassword)