fs: Remove inode null check from file_dup and fs_dupfd2

since the same check already done in file_dup2

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I7ba1309c55be1ac564f798df02fc6725c4a0d469
This commit is contained in:
Xiang Xiao 2021-01-02 23:31:07 +08:00 committed by Abdelatif Guettouche
parent dd26d9c9f9
commit 63bc3efd25
3 changed files with 6 additions and 38 deletions

View File

@ -188,6 +188,11 @@ int file_dup2(FAR struct file *filep1, FAR struct file *filep2)
return -EBADF;
}
if (filep1 == filep2)
{
return OK;
}
list = nxsched_get_files();
/* The file list can be NULL under two cases: (1) One is an obscure

View File

@ -32,12 +32,6 @@
#include "inode/inode.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define DUP_ISOPEN(filep) (filep->f_inode != NULL)
/****************************************************************************
* Public Functions
****************************************************************************/
@ -61,14 +55,7 @@ int file_dup(FAR struct file *filep, int minfd)
int fd2;
int ret;
/* Verify that fd is a valid, open file descriptor */
if (!DUP_ISOPEN(filep))
{
return -EBADF;
}
/* Then allocate a new file descriptor for the inode */
/* Allocate a new file descriptor for the inode */
fd2 = files_allocate(NULL, 0, 0, minfd);
if (fd2 < 0)

View File

@ -46,16 +46,6 @@
#include "inode/inode.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define DUP_ISOPEN(filep) (filep->f_inode != NULL)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -93,20 +83,6 @@ int fs_dupfd2(int fd1, int fd2)
DEBUGASSERT(filep1 != NULL && filep2 != NULL);
/* Verify that fd1 is a valid, open file descriptor */
if (!DUP_ISOPEN(filep1))
{
return -EBADF;
}
/* Handle a special case */
if (fd1 == fd2)
{
return fd1;
}
/* Perform the dup2 operation */
return file_dup2(filep1, filep2);