Skip to content

Commit

Permalink
fs: fix comment in apache#15163
Browse files Browse the repository at this point in the history
Signed-off-by: hujun5 <hujun5@xiaomi.com>
  • Loading branch information
hujun260 authored and anchao committed Dec 16, 2024
1 parent c7a0288 commit 7036098
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions fs/inode/fs_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,15 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,

filep = &list->fl_files[l1][l2];
#ifdef CONFIG_FS_REFCOUNT
int32_t refs = 0;

if (filep->f_inode != NULL)
{
/* When the reference count is zero but the inode has not yet been
* released, At this point we should return a null pointer
*/

int32_t refs = atomic_read(&filep->f_refs);
do
{
refs = atomic_read(&filep->f_refs);
if (refs == 0)
{
filep = NULL;
Expand All @@ -99,18 +97,12 @@ static FAR struct file *files_fget_by_index(FAR struct filelist *list,
{
filep = NULL;
}
else
else if (atomic_fetch_add(&filep->f_refs, 1) == 0)
{
do
{
if (atomic_cmpxchg(&filep->f_refs, &refs, 2))
{
*new = true;
break;
}
}
while (!atomic_try_cmpxchg(&filep->f_refs, &refs, refs + 1));
atomic_fetch_add(&filep->f_refs, 1);
*new = true;
}

#else
if (filep->f_inode == NULL && new == NULL)
{
Expand Down

0 comments on commit 7036098

Please sign in to comment.