Skip to content

Commit

Permalink
fs/inode: remove unnecessary return value for inode_addrefs
Browse files Browse the repository at this point in the history
Signed-off-by: dongjiuzhu1 <[email protected]>
  • Loading branch information
Donny9 authored and xiaoxiang781216 committed Oct 1, 2024
1 parent 09a9611 commit b2e69b8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 43 deletions.
4 changes: 1 addition & 3 deletions fs/inode/fs_inodeaddref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion fs/inode/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
25 changes: 9 additions & 16 deletions fs/shm/shmfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions fs/vfs/fs_dup2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
30 changes: 12 additions & 18 deletions fs/vfs/fs_pseudofile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b2e69b8

Please sign in to comment.