Skip to content

Commit 271f765

Browse files
crafcat7xiaoxiang781216
authored andcommitted
fs_lock/pathbuffer:Optimize code structure
Summary: Adjust code logic Signed-off-by: chenrun1 <[email protected]>
1 parent 36a8ff0 commit 271f765

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

fs/vfs/fs_lock.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ int file_getlk(FAR struct file *filep, FAR struct flock *flock)
610610

611611
out_free:
612612
lib_put_pathbuffer(path);
613-
return OK;
613+
return ret;
614614
}
615615

616616
/****************************************************************************
@@ -756,7 +756,7 @@ void file_closelk(FAR struct file *filep)
756756
bool deleted = false;
757757
int ret;
758758

759-
if (filep->locked == false)
759+
if (!filep->locked)
760760
{
761761
return;
762762
}
@@ -774,7 +774,7 @@ void file_closelk(FAR struct file *filep)
774774
* it.
775775
*/
776776

777-
goto out;
777+
goto out_free;
778778
}
779779

780780
nxmutex_lock(&g_protect_lock);
@@ -783,7 +783,6 @@ void file_closelk(FAR struct file *filep)
783783
{
784784
/* There is no bucket here, so we don't need to free it. */
785785

786-
nxmutex_unlock(&g_protect_lock);
787786
goto out;
788787
}
789788

@@ -807,8 +806,9 @@ void file_closelk(FAR struct file *filep)
807806
file_lock_delete_bucket(bucket, path);
808807
}
809808

810-
nxmutex_unlock(&g_protect_lock);
811809
out:
810+
nxmutex_unlock(&g_protect_lock);
811+
out_free:
812812
lib_put_pathbuffer(path);
813813
}
814814

libs/libc/misc/lib_pathbuffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
struct pathbuffer_s
4141
{
42-
mutex_t lock; /* Lock for the buffer */
43-
int free_bitmap; /* Bitmap of free buffer */
42+
mutex_t lock; /* Lock for the buffer */
43+
unsigned int free_bitmap; /* Bitmap of free buffer */
4444
char buffer[CONFIG_LIBC_MAX_PATHBUFFER][PATH_MAX];
4545
};
4646

0 commit comments

Comments
 (0)