fs_lock/pathbuffer:Optimize code structure

Summary:
  Adjust code logic

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
This commit is contained in:
chenrun1 2024-08-21 11:06:27 +08:00 committed by Xiang Xiao
parent 36a8ff0540
commit 271f76590f
2 changed files with 7 additions and 7 deletions

View file

@ -610,7 +610,7 @@ out:
out_free: out_free:
lib_put_pathbuffer(path); lib_put_pathbuffer(path);
return OK; return ret;
} }
/**************************************************************************** /****************************************************************************
@ -756,7 +756,7 @@ void file_closelk(FAR struct file *filep)
bool deleted = false; bool deleted = false;
int ret; int ret;
if (filep->locked == false) if (!filep->locked)
{ {
return; return;
} }
@ -774,7 +774,7 @@ void file_closelk(FAR struct file *filep)
* it. * it.
*/ */
goto out; goto out_free;
} }
nxmutex_lock(&g_protect_lock); nxmutex_lock(&g_protect_lock);
@ -783,7 +783,6 @@ void file_closelk(FAR struct file *filep)
{ {
/* There is no bucket here, so we don't need to free it. */ /* There is no bucket here, so we don't need to free it. */
nxmutex_unlock(&g_protect_lock);
goto out; goto out;
} }
@ -807,8 +806,9 @@ void file_closelk(FAR struct file *filep)
file_lock_delete_bucket(bucket, path); file_lock_delete_bucket(bucket, path);
} }
nxmutex_unlock(&g_protect_lock);
out: out:
nxmutex_unlock(&g_protect_lock);
out_free:
lib_put_pathbuffer(path); lib_put_pathbuffer(path);
} }

View file

@ -40,7 +40,7 @@
struct pathbuffer_s struct pathbuffer_s
{ {
mutex_t lock; /* Lock for the buffer */ mutex_t lock; /* Lock for the buffer */
int free_bitmap; /* Bitmap of free buffer */ unsigned int free_bitmap; /* Bitmap of free buffer */
char buffer[CONFIG_LIBC_MAX_PATHBUFFER][PATH_MAX]; char buffer[CONFIG_LIBC_MAX_PATHBUFFER][PATH_MAX];
}; };