Copilot commented on code in PR #21827:
URL: https://github.com/apache/nuttx/pull/21827#discussion_r4561483020


##########
fs/vfs/fs_rename.c:
##########
@@ -73,9 +73,7 @@ static int pseudorename(FAR const char *oldpath, FAR struct 
inode *oldinode,
   struct inode_search_s newdesc;
   FAR struct inode *newinode;
   FAR char *subdir = NULL;
-#ifdef CONFIG_FS_NOTIFY
   bool isdir = INODE_IS_PSEUDODIR(oldinode);

Review Comment:
   `isdir` is ambiguous in a rename implementation that deals with both source 
and destination inodes/paths. Consider renaming to something explicit like 
`old_isdir` (or `old_isdir_pseudodir`) to make it clear this refers to 
`oldinode`.



##########
fs/vfs/fs_rename.c:
##########
@@ -183,6 +181,14 @@ static int pseudorename(FAR const char *oldpath, FAR 
struct inode *oldinode,
            * won't really be removed until we call inode_release();
            */
 
+          if (isdir)
+            {
+              /* It is an error to rename a directory to a file */

Review Comment:
   The new behavior is specifically about renaming a directory onto an 
*existing* non-directory target. Updating the comment to reflect that nuance 
(e.g., \"rename a directory over an existing file\") would better document why 
this branch returns `-ENOTDIR` 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to