This is an automated email from the ASF dual-hosted git repository.
archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 7036098d23 fs: fix comment in
https://github.com/apache/nuttx/pull/15163
7036098d23 is described below
commit 7036098d237383ae80c91f710cab33fb2299da55
Author: hujun5 <[email protected]>
AuthorDate: Mon Dec 16 12:15:05 2024 +0800
fs: fix comment in https://github.com/apache/nuttx/pull/15163
Signed-off-by: hujun5 <[email protected]>
---
fs/inode/fs_files.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/fs/inode/fs_files.c b/fs/inode/fs_files.c
index 5135a856b6..c830ba864e 100644
--- a/fs/inode/fs_files.c
+++ b/fs/inode/fs_files.c
@@ -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;
@@ -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)
{