From f82be437b94a43e5241950b50f1d5a2fee30465d Mon Sep 17 00:00:00 2001 From: mucor Date: Tue, 30 Mar 2021 10:49:55 +0800 Subject: [PATCH] change while loop to for loop Change-Id: Ie5c0cbca1e94c97ee2f511bf5ee3cdfb8c085a79 --- fs/vfs/operation/fs_file_mapping.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/vfs/operation/fs_file_mapping.c b/fs/vfs/operation/fs_file_mapping.c index 22cbca4f..d976f47b 100644 --- a/fs/vfs/operation/fs_file_mapping.c +++ b/fs/vfs/operation/fs_file_mapping.c @@ -247,7 +247,6 @@ out: int update_file_path(const char *old_path, const char *new_path) { - unsigned int i = 3; struct filelist *f_list = NULL; struct file *filp = NULL; int ret; @@ -260,12 +259,11 @@ int update_file_path(const char *old_path, const char *new_path) } (VOID)LOS_MuxLock(&g_file_mapping.lock, LOS_WAIT_FOREVER); - while (i < CONFIG_NFILE_DESCRIPTORS) { - i++; - if (!get_bit(i - 1)) { + for (int i = 3; i < CONFIG_NFILE_DESCRIPTORS; i++) { + if (!get_bit(i)) { continue; } - filp = &tg_filelist.fl_files[i - 1]; + filp = &tg_filelist.fl_files[i]; if (filp->f_path == NULL || strcmp(filp->f_path, old_path)) { continue; }