True, more or less. It's more a question for the reader. True. Right. True, it's effectively the same as the upper 29 bits are random anyway and the bottom 3 bits are always set. Likely. And it was a
That makes no difference - the compiler will generate the same code. The real question is WTF is the code doing? The '& ~7u' clears the bottom 3 bits. The '- 1' then sets the bottom 3 bits and decrem
[] [] trivia: There are somewhat odd size mismatches here. I had to think a tiny bit if random() returned a value from 0 to 7 and was promoted to a 64 bit value then truncated to 32 bit. Perhaps thes
Author: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Date: Thu, 6 Oct 2022 16:20:31 +0300
... Shouldn't the two first 7s to be 3s? ... We have some 24-bit APIs (and 48-bit) already in kernel, why not to have get_random_u24() ? -- With Best Regards, Andy Shevchenko