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;