[libc-commits] [PATCH] D147981: [LIBC] Fix `getrandom` success return value

Noah Goldstein via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Apr 11 12:05:16 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: libc/test/src/sys/random/linux/getrandom_test.cpp:35
+  uint8_t buf[SIZE];
+  for (size_t i = 0; i < SIZE; i += 1 + (i % 64)) {
+    // Without GRND_RANDOM set, this should never fail
----------------
michaelrj wrote:
> I'm not sure why the mod operation is here, maybe add a comment explaining?
> I'm not sure why the mod operation is here, maybe add a comment explaining?

Its just meant to be a compromise between not doing every single value and getting a decent spread. Could also be `rand % 64` or something like that, but figured that might make test harder to reproduce.

`64` should probably be a prime in retrospect.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147981/new/

https://reviews.llvm.org/D147981



More information about the libc-commits mailing list