pussuw commented on code in PR #16361:
URL: https://github.com/apache/nuttx/pull/16361#discussion_r2086067813


##########
fs/inode/fs_files.c:
##########
@@ -266,25 +402,18 @@ static void task_fssync(FAR struct tcb_s *tcb, FAR void 
*arg)
  *
  ****************************************************************************/
 
-static int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2,
-                            int flags)
+int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2, int flags)
 {
-  FAR struct filelist *list;
+  FAR struct fdlist *list;
   FAR struct file *filep1;
-  FAR struct file *filep;
-#ifdef CONFIG_FDCHECK
-  uint8_t f_tag_fdcheck;
-#endif
-#ifdef CONFIG_FDSAN
-  uint64_t f_tag_fdsan;
-#endif
-  bool new = false;
+  FAR struct file *filep2;
+  struct fd_flags fdflags;
   int count;
   int ret;
 
   if (fd1 == fd2)
     {
-      return fd1;
+      return -EINVAL;

Review Comment:
   No, the old implementation was simply wrong.
   
   The dup3() function shall be equivalent to the dup2() function, except that 
it shall be an error if fildes is equal to fildes2. You need to return -EINVAL 
if fd1 == fd2. This is fixed here.



##########
fs/inode/fs_files.c:
##########
@@ -266,25 +402,18 @@ static void task_fssync(FAR struct tcb_s *tcb, FAR void 
*arg)
  *
  ****************************************************************************/
 
-static int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2,
-                            int flags)
+int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2, int flags)
 {
-  FAR struct filelist *list;
+  FAR struct fdlist *list;
   FAR struct file *filep1;
-  FAR struct file *filep;
-#ifdef CONFIG_FDCHECK
-  uint8_t f_tag_fdcheck;
-#endif
-#ifdef CONFIG_FDSAN
-  uint64_t f_tag_fdsan;
-#endif
-  bool new = false;
+  FAR struct file *filep2;
+  struct fd_flags fdflags;
   int count;
   int ret;
 
   if (fd1 == fd2)
     {
-      return fd1;
+      return -EINVAL;

Review Comment:
   No, the old implementation was simply wrong.
   `
   The dup3() function shall be equivalent to the dup2() function, except that 
it shall be an error if fildes is equal to fildes2. You need to return -EINVAL 
if fd1 == fd2. This is fixed here.`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to