Donny9 commented on code in PR #16499:
URL: https://github.com/apache/nuttx/pull/16499#discussion_r2135960775


##########
fs/inode/fs_files.c:
##########
@@ -258,70 +292,43 @@ static void task_fssync(FAR struct tcb_s *tcb, FAR void 
*arg)
  *
  ****************************************************************************/
 
-int nx_dup3_from_tcb(FAR struct tcb_s *tcb, int fd1, int fd2, int flags)
+int fdlist_dup3(FAR struct fdlist *list, int fd1, int fd2, int flags)
 {
-  FAR struct filelist *list;
   FAR struct file *filep1;
-  FAR struct file *filep;
-  bool new = false;
-  int count;
   int ret;
 
   if (fd1 == fd2)
     {
-      return fd1;
+      return -EINVAL;
     }
 
 #ifdef CONFIG_FDCHECK
-  fd1 = fdcheck_restore(fd1);
   fd2 = fdcheck_restore(fd2);
 #endif
 
   /* Get the file descriptor list.  It should not be NULL in this context. */
 
-  list = nxsched_get_files_from_tcb(tcb);
-  count = files_countlist(list);
-
-  if (fd1 < 0 || fd1 >= count || fd2 < 0)
+  if (fd2 < 0)
     {
       return -EBADF;
     }
 
-  if (fd2 >= count)
-    {
-      ret = files_extend(list, fd2 / CONFIG_NFILE_DESCRIPTORS_PER_BLOCK + 1);
-      if (ret < 0)
-        {
-          return ret;
-        }
-    }
-
-  filep1 = files_fget(list, fd1);
-  if (filep1 == NULL)
+  ret = fdlist_extend(list,

Review Comment:
   line 102 check this value



-- 
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