casaroli commented on code in PR #21902:
URL: https://github.com/apache/nuttx/pull/21902#discussion_r4612701152


##########
libs/libc/stdlib/lib_arc4random.c:
##########
@@ -25,14 +25,48 @@
  ****************************************************************************/
 
 #include <errno.h>
+#include <fcntl.h>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/param.h>
 #include <sys/random.h>
 #include <time.h>
+#include <unistd.h>
 
+#include <nuttx/fs/fs.h>
 #include <nuttx/hashtable.h>
+#include <nuttx/random.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* The flat build and the kernel copy read the device through a file of
+ * their own: a descriptor or the errno of the caller does not change.
+ */
+
+#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__)
+#  define RANDOM_OPEN(f, p)    file_open(f, p, O_RDONLY)

Review Comment:
   `_NX_OPEN` gives a descriptor in the table of the caller, and its users need 
that descriptor: the stdio streams, `lib_getrandom.c`, the ELF loader. 
`arc4random_buf()` must not take a descriptor of the caller or change its 
errno, so it uses `file_open()` with a `struct file`, which has no descriptor. 
A change of `_NX_OPEN` would change all those users.
   



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