From: Mike Bradeen Date: Tue, 29 Aug 2023 15:35:46 +0000 (-0600) Subject: app_voicemail: Fix for loop declarations X-Git-Tag: 18.20.0-rc1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e2cb7ecb13879bdfd4d2dce3f72279219f2f0f3;p=thirdparty%2Fasterisk.git app_voicemail: Fix for loop declarations Resolve for loop initial declarations added in cli changes. Resolves: #275 (cherry picked from commit 62480fd91b7f5cdddb3bbe27e690b521e3e84633) --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index a10a38ef35..277d22c393 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -11581,6 +11581,7 @@ static int show_mailbox_snapshot(struct ast_cli_args *a) const char *context = a->argv[4]; struct ast_vm_mailbox_snapshot *mailbox_snapshot; struct ast_vm_msg_snapshot *msg; + int i; /* Take a snapshot of the mailbox and walk through each folder's contents */ mailbox_snapshot = ast_vm_mailbox_snapshot_create(mailbox, context, NULL, 0, AST_VM_SNAPSHOT_SORT_BY_ID, 0); @@ -11591,7 +11592,7 @@ static int show_mailbox_snapshot(struct ast_cli_args *a) ast_cli(a->fd, VM_STRING_HEADER_FORMAT, "Folder", "Caller ID", "Date", "Duration", "Flag", "ID"); - for (int i = 0; i < mailbox_snapshot->folders; i++) { + for (i = 0; i < mailbox_snapshot->folders; i++) { AST_LIST_TRAVERSE(&((mailbox_snapshot)->snapshots[i]), msg, msg) { ast_cli(a->fd, VM_STRING_HEADER_FORMAT, msg->folder_name, msg->callerid, msg->origdate, msg->duration, msg->flag, msg->msg_id); @@ -11808,9 +11809,10 @@ static char *complete_voicemail_move_message(struct ast_cli_args *a, int maxpos) } AST_LIST_UNLOCK(&users); } else if (pos == 4 || pos == 8 || (pos == 6 && maxpos == 6) ) { + int i; /* Walk through the standard folders */ wordlen = strlen(word); - for (int i = 0; i < ARRAY_LEN(mailbox_folders); i++) { + for (i = 0; i < ARRAY_LEN(mailbox_folders); i++) { if (folder && !strncasecmp(word, mailbox_folders[i], wordlen) && ++which > state) { return ast_strdup(mailbox_folders[i]); } @@ -11820,7 +11822,6 @@ static char *complete_voicemail_move_message(struct ast_cli_args *a, int maxpos) /* find messages in the folder */ struct ast_vm_mailbox_snapshot *mailbox_snapshot; struct ast_vm_msg_snapshot *msg; - int i = 0; mailbox = a->argv[2]; context = a->argv[3]; folder = a->argv[4]; @@ -11828,6 +11829,7 @@ static char *complete_voicemail_move_message(struct ast_cli_args *a, int maxpos) /* Take a snapshot of the mailbox and snag the individual info */ if ((mailbox_snapshot = ast_vm_mailbox_snapshot_create(mailbox, context, folder, 0, AST_VM_SNAPSHOT_SORT_BY_ID, 0))) { + int i; /* we are only requesting the one folder, but we still need to know it's index */ for (i = 0; i < ARRAY_LEN(mailbox_folders); i++) { if (!strcasecmp(mailbox_folders[i], folder)) { @@ -13804,6 +13806,7 @@ static int append_vmbox_info_astman( struct ast_vm_mailbox_snapshot *mailbox_snapshot; struct ast_vm_msg_snapshot *msg; int nummessages = 0; + int i; /* Take a snapshot of the mailbox */ mailbox_snapshot = ast_vm_mailbox_snapshot_create(vmu->mailbox, vmu->context, NULL, 0, AST_VM_SNAPSHOT_SORT_BY_ID, 0); @@ -13815,7 +13818,7 @@ static int append_vmbox_info_astman( astman_send_listack(s, m, "Voicemail box detail will follow", "start"); /* walk through each folder's contents and append info for each message */ - for (int i = 0; i < mailbox_snapshot->folders; i++) { + for (i = 0; i < mailbox_snapshot->folders; i++) { AST_LIST_TRAVERSE(&((mailbox_snapshot)->snapshots[i]), msg, msg) { astman_append(s, "Event: %s\r\n"