This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 271f76590f2237c70bab6fea2b90be2bdc944288
Author: chenrun1 <[email protected]>
AuthorDate: Wed Aug 21 11:06:27 2024 +0800

    fs_lock/pathbuffer:Optimize code structure
    
    Summary:
      Adjust code logic
    
    Signed-off-by: chenrun1 <[email protected]>
---
 fs/vfs/fs_lock.c                | 10 +++++-----
 libs/libc/misc/lib_pathbuffer.c |  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/vfs/fs_lock.c b/fs/vfs/fs_lock.c
index 1c4bb006f9..25e63e8c36 100644
--- a/fs/vfs/fs_lock.c
+++ b/fs/vfs/fs_lock.c
@@ -610,7 +610,7 @@ out:
 
 out_free:
   lib_put_pathbuffer(path);
-  return OK;
+  return ret;
 }
 
 /****************************************************************************
@@ -756,7 +756,7 @@ void file_closelk(FAR struct file *filep)
   bool deleted = false;
   int ret;
 
-  if (filep->locked == false)
+  if (!filep->locked)
     {
       return;
     }
@@ -774,7 +774,7 @@ void file_closelk(FAR struct file *filep)
        * it.
        */
 
-      goto out;
+      goto out_free;
     }
 
   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. */
 
-      nxmutex_unlock(&g_protect_lock);
       goto out;
     }
 
@@ -807,8 +806,9 @@ void file_closelk(FAR struct file *filep)
       file_lock_delete_bucket(bucket, path);
     }
 
-  nxmutex_unlock(&g_protect_lock);
 out:
+  nxmutex_unlock(&g_protect_lock);
+out_free:
   lib_put_pathbuffer(path);
 }
 
diff --git a/libs/libc/misc/lib_pathbuffer.c b/libs/libc/misc/lib_pathbuffer.c
index 78ebff94ce..4beac475a5 100644
--- a/libs/libc/misc/lib_pathbuffer.c
+++ b/libs/libc/misc/lib_pathbuffer.c
@@ -39,8 +39,8 @@
 
 struct pathbuffer_s
 {
-  mutex_t lock;         /* Lock for the buffer */
-  int free_bitmap;      /* Bitmap of free buffer */
+  mutex_t lock;             /* Lock for the buffer */
+  unsigned int free_bitmap; /* Bitmap of free buffer */
   char buffer[CONFIG_LIBC_MAX_PATHBUFFER][PATH_MAX];
 };
 

Reply via email to