Page MenuHomeFreeBSD

random(4): Translate a comment requirement into a compile-time invariant
ClosedPublic

Authored by cem on Sep 1 2018, 4:39 AM.

Details

Summary

In various places, random represents the set of sources as a 32-bit word
bitmask. It assumes all sources fit within this, i.e., the maximum valid
source number is 31.

There was a comment specifying this limitation, but we can actually refuse
to compile if our assumption is violated instead. We still have a few spare
random source slots, but sooner or later someone may need to convert the
masks used from raw 32-bit words to bitset(9) APIs.

This prevents some kinds of developer foot-shooting when adding new random
sources. No functional change.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

cem created this revision.Sep 1 2018, 4:39 AM
delphij accepted this revision.Sep 1 2018, 5:44 AM
delphij added a subscriber: delphij.

LGTM.

This revision is now accepted and ready to land.Sep 1 2018, 5:44 AM
markm accepted this revision.Sep 1 2018, 10:05 AM
This revision was automatically updated to reflect the committed changes.