You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/01 17:56:57 UTC
(nuttx) 04/04: fs/inode: remove unnecessary return value for inode_addrefs
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 b2e69b86ada161e2d8b738ab7af6462f73247272
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Tue Oct 1 22:23:12 2024 +0800
fs/inode: remove unnecessary return value for inode_addrefs
Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
---
fs/inode/fs_inodeaddref.c | 4 +---
fs/inode/inode.h | 2 +-
fs/shm/shmfs.c | 25 +++++++++----------------
fs/vfs/fs_dup2.c | 6 +-----
fs/vfs/fs_pseudofile.c | 30 ++++++++++++------------------
5 files changed, 24 insertions(+), 43 deletions(-)
diff --git a/fs/inode/fs_inodeaddref.c b/fs/inode/fs_inodeaddref.c
index af3dacd59b..abfb4a77c6 100644
--- a/fs/inode/fs_inodeaddref.c
+++ b/fs/inode/fs_inodeaddref.c
@@ -41,12 +41,10 @@
*
****************************************************************************/
-int inode_addref(FAR struct inode *inode)
+void inode_addref(FAR struct inode *inode)
{
if (inode)
{
atomic_fetch_add(&inode->i_crefs, 1);
}
-
- return OK;
}
diff --git a/fs/inode/inode.h b/fs/inode/inode.h
index e6aa04ac18..1e7081e0db 100644
--- a/fs/inode/inode.h
+++ b/fs/inode/inode.h
@@ -392,7 +392,7 @@ int inode_remove(FAR const char *path);
*
****************************************************************************/
-int inode_addref(FAR struct inode *inode);
+void inode_addref(FAR struct inode *inode);
/****************************************************************************
* Name: inode_release
diff --git a/fs/shm/shmfs.c b/fs/shm/shmfs.c
index fb0b94116b..f73dc35969 100644
--- a/fs/shm/shmfs.c
+++ b/fs/shm/shmfs.c
@@ -350,24 +350,17 @@ static int shmfs_mmap(FAR struct file *filep,
/* Keep the inode when mmapped, increase refcount */
- ret = inode_addref(filep->f_inode);
- if (ret >= 0)
+ inode_addref(filep->f_inode);
+ object = filep->f_inode->i_private;
+ if (object)
{
- object = filep->f_inode->i_private;
- if (object)
- {
- ret = shmfs_map_object(object, &entry->vaddr);
- }
- else
- {
- ret = -EINVAL;
- }
+ ret = shmfs_map_object(object, &entry->vaddr);
+ }
- if (ret < 0 ||
- (ret = shmfs_add_map(entry, filep->f_inode)) < 0)
- {
- inode_release(filep->f_inode);
- }
+ if (ret < 0 ||
+ (ret = shmfs_add_map(entry, filep->f_inode)) < 0)
+ {
+ inode_release(filep->f_inode);
}
return ret;
diff --git a/fs/vfs/fs_dup2.c b/fs/vfs/fs_dup2.c
index 154331afc7..7d70166b24 100644
--- a/fs/vfs/fs_dup2.c
+++ b/fs/vfs/fs_dup2.c
@@ -78,11 +78,7 @@ int file_dup3(FAR struct file *filep1, FAR struct file *filep2, int flags)
/* Increment the reference count on the contained inode */
inode = filep1->f_inode;
- ret = inode_addref(inode);
- if (ret < 0)
- {
- return ret;
- }
+ inode_addref(inode);
/* If there is already an inode contained in the new file structure,
* close the file and release the inode.
diff --git a/fs/vfs/fs_pseudofile.c b/fs/vfs/fs_pseudofile.c
index 57b2601beb..a430b6dd25 100644
--- a/fs/vfs/fs_pseudofile.c
+++ b/fs/vfs/fs_pseudofile.c
@@ -314,29 +314,23 @@ static int pseudofile_mmap(FAR struct file *filep,
{
FAR struct inode *node = filep->f_inode;
FAR struct fs_pseudofile_s *pf = node->i_private;
+ int ret = -EINVAL;
/* Keep the inode when mmapped, increase refcount */
- int ret = inode_addref(node);
- if (ret >= 0)
+ inode_addref(node);
+ if (map->offset >= 0 && map->offset < node->i_size &&
+ map->length != 0 && map->offset + map->length <= node->i_size)
{
- if (map->offset >= 0 && map->offset < node->i_size &&
- map->length != 0 && map->offset + map->length <= node->i_size)
- {
- map->vaddr = pf->content + map->offset;
- map->munmap = pseudofile_munmap;
- map->priv.p = (FAR void *)node;
- ret = mm_map_add(get_current_mm(), map);
- }
- else
- {
- ret = -EINVAL;
- }
+ map->vaddr = pf->content + map->offset;
+ map->munmap = pseudofile_munmap;
+ map->priv.p = (FAR void *)node;
+ ret = mm_map_add(get_current_mm(), map);
+ }
- if (ret < 0)
- {
- inode_release(node);
- }
+ if (ret < 0)
+ {
+ inode_release(node);
}
return ret;