fs/inode: remove unnecessary return value for inode_addrefs

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2024-10-01 22:23:12 +08:00
committed by Xiang Xiao
parent 09a9611ae9
commit b2e69b86ad
5 changed files with 24 additions and 43 deletions
+1 -3
View File
@@ -41,12 +41,10 @@
* *
****************************************************************************/ ****************************************************************************/
int inode_addref(FAR struct inode *inode) void inode_addref(FAR struct inode *inode)
{ {
if (inode) if (inode)
{ {
atomic_fetch_add(&inode->i_crefs, 1); atomic_fetch_add(&inode->i_crefs, 1);
} }
return OK;
} }
+1 -1
View File
@@ -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 * Name: inode_release
+9 -16
View File
@@ -350,24 +350,17 @@ static int shmfs_mmap(FAR struct file *filep,
/* Keep the inode when mmapped, increase refcount */ /* Keep the inode when mmapped, increase refcount */
ret = inode_addref(filep->f_inode); inode_addref(filep->f_inode);
if (ret >= 0) object = filep->f_inode->i_private;
if (object)
{ {
object = filep->f_inode->i_private; ret = shmfs_map_object(object, &entry->vaddr);
if (object) }
{
ret = shmfs_map_object(object, &entry->vaddr);
}
else
{
ret = -EINVAL;
}
if (ret < 0 || if (ret < 0 ||
(ret = shmfs_add_map(entry, filep->f_inode)) < 0) (ret = shmfs_add_map(entry, filep->f_inode)) < 0)
{ {
inode_release(filep->f_inode); inode_release(filep->f_inode);
}
} }
return ret; return ret;
+1 -5
View File
@@ -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 */ /* Increment the reference count on the contained inode */
inode = filep1->f_inode; inode = filep1->f_inode;
ret = inode_addref(inode); inode_addref(inode);
if (ret < 0)
{
return ret;
}
/* If there is already an inode contained in the new file structure, /* If there is already an inode contained in the new file structure,
* close the file and release the inode. * close the file and release the inode.
+12 -18
View File
@@ -314,29 +314,23 @@ static int pseudofile_mmap(FAR struct file *filep,
{ {
FAR struct inode *node = filep->f_inode; FAR struct inode *node = filep->f_inode;
FAR struct fs_pseudofile_s *pf = node->i_private; FAR struct fs_pseudofile_s *pf = node->i_private;
int ret = -EINVAL;
/* Keep the inode when mmapped, increase refcount */ /* Keep the inode when mmapped, increase refcount */
int ret = inode_addref(node); inode_addref(node);
if (ret >= 0) 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->vaddr = pf->content + map->offset;
map->length != 0 && map->offset + map->length <= node->i_size) map->munmap = pseudofile_munmap;
{ map->priv.p = (FAR void *)node;
map->vaddr = pf->content + map->offset; ret = mm_map_add(get_current_mm(), map);
map->munmap = pseudofile_munmap; }
map->priv.p = (FAR void *)node;
ret = mm_map_add(get_current_mm(), map);
}
else
{
ret = -EINVAL;
}
if (ret < 0) if (ret < 0)
{ {
inode_release(node); inode_release(node);
}
} }
return ret; return ret;