yamt commented on PR #10925: URL: https://github.com/apache/nuttx/pull/10925#issuecomment-1772130962
> > > > i feel it involves too many `#ifdef`s in every applications. > > > > ``` > > > > #if check config for /dev/random and/or /dev/urandom > > > > use getrandom > > > > #elif check config for arc4random_buf > > > > use arc4random_buf > > > > #else > > > > fallback or error > > > > #endif > > > > ``` > > > > > > > > > Otherwise, you need if/else if, so I prefer to detect the error before running. For example, you may even not notice that: https://github.com/yamt/toywasm/blob/master/libwasi/wasi.c#L2452C12-L2452C12 the above code mayn't work as expect if you forget to enable DEV_RANDOM or DEV_URANDOM. But with this patch, we can find and fix it. > > > > > > the cited code returns an error, doesn't it? at least it was my expectation. > > In this case, getrandom always report error which isn't a runtime error. Why do you prefer a compiler/link time error decay to a runtime error? Since C/C++ language prefer to find the error as early as possible, it's better to let the linker report the error, or the caller add explicit #ifdef/#else/#endif in the code. because the lack of PRNG is not always critical for applications. -- 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