xiaoxiang781216 commented on code in PR #19016:
URL: https://github.com/apache/nuttx/pull/19016#discussion_r3341055784
##########
libs/libc/dirent/lib_readdir.c:
##########
@@ -67,11 +68,22 @@ FAR struct dirent *readdir(DIR *dirp)
return NULL;
}
+ /* Save errno so it can be restored on end-of-directory. POSIX requires
+ * errno to be unchanged at EOF, but the read() path may not preserve it.
+ */
+
+ errcode = get_errno();
+
ret = read(dirp->fd, &dirp->entry, sizeof(struct dirent));
- if (ret <= 0)
+ if (ret == 0)
Review Comment:
but read shouldn't change errno if it returns zero.
--
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]