xiaoxiang781216 edited a comment on pull request #2497: URL: https://github.com/apache/incubator-nuttx/pull/2497#issuecomment-742594299
> > Please fix the low entropy case too: > > https://github.com/apache/incubator-nuttx/pull/2497/files#diff-ee6b9d93e85a2c9b845acc6c4fdcef1c9cca9ee4166cadd7b15f889f221065e7L330 > > This patch fixes a real bug. The low entropy / API interface design discussion is a separate item not really related to this PR. > > > But, anyway this PR doesn't resolve the real problem, we should follow FreeBSD and Linux prototype: > > https://man7.org/linux/man-pages/man2/getrandom.2.html > > https://www.freebsd.org/cgi/man.cgi?query=getrandom&sektion=2&manpath=freebsd-release-ports > > If we allow the contributor to modify the public function prototype, NuttX will lose the compability in the long run. > > Compatibility with what? getrandom() is Linux / Glibc specific non-portable interface not commonly used elsewhere. OpenBSD, NetBSD and Mac use arc4random() functions, which are also available for FreeBSD and Android (with a different name I recall) as well. > at least, three libc(glibc, musl and bionic) implement getrandom: https://github.com/bminor/musl/blob/master/include/sys/random.h#L15 https://github.com/aosp-mirror/platform_bionic/blob/master/libc/include/sys/random.h#L65 > > If you still insist to not change getrandom prototype to confirm the standard, I will create a patch remove it from the code base because it is a bad showcase which violate INVIOLABLES rule. > > getrandom() is a Linux / Glibc specific function. It is not part of any standard. What standard are you talking about? Please specify exact chapter and verse quatation from this (so far unknown) standard that specifies the prototype and behavior of getrandom(). Linux man pages are not a standard! Your prototype is not any more correct than the existing one. Which INVIOLABLES rule says that NuttX APIs must conform to Linux man pages? Does INVIOLABLES allow you to define a new API doesn't come from any POSIX like OS? If POSIX has the definition, NuttX must follow it. But if some functions are very useful but not specificied in POSIX, we normally follow FreeBSD or Linux. So nobody has the right to add a syscall which not specified in POSIX, FreeBSD or Linux. In this case, two solution exist: 1. Fix the prototype of getrandom to confirm man's defintion 2. Implement arc4random_buf and remove getrandom If you don't like both approach, the best thing is to remove getrandom from the code base. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org