Commit b0c3e79
committed
random: make random_get_entropy() return an unsigned long
Some implementations were returning type `unsigned long`, while others
that fell back to get_cycles() were implicitly returning a `cycles_t` or
an untyped constant int literal. That makes for weird and confusing
code, and basically all code in the kernel already handled it like it
was an `unsigned long`. I recently tried to handle it as the largest
type it could be, a `cycles_t`, but doing so doesn't really help with
much.
Instead let's just make random_get_entropy() return an unsigned long all
the time. This also matches the commonly used `arch_get_random_long()`
function, so now RDRAND and RDTSC return the same sized integer, which
means one can fallback to the other more gracefully.
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Theodore Ts'o <tytso@mit.edu>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>1 parent 5209aed commit b0c3e79
2 files changed
Lines changed: 8 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
1021 | | - | |
| 1021 | + | |
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
| |||
1049 | 1049 | | |
1050 | 1050 | | |
1051 | 1051 | | |
1052 | | - | |
1053 | | - | |
| 1052 | + | |
1054 | 1053 | | |
1055 | 1054 | | |
1056 | 1055 | | |
| |||
1339 | 1338 | | |
1340 | 1339 | | |
1341 | 1340 | | |
1342 | | - | |
1343 | | - | |
| 1341 | + | |
1344 | 1342 | | |
1345 | 1343 | | |
1346 | 1344 | | |
| |||
1353 | 1351 | | |
1354 | 1352 | | |
1355 | 1353 | | |
1356 | | - | |
| 1354 | + | |
1357 | 1355 | | |
1358 | | - | |
| 1356 | + | |
| 1357 | + | |
1359 | 1358 | | |
1360 | 1359 | | |
1361 | | - | |
1362 | | - | |
1363 | | - | |
1364 | | - | |
1365 | | - | |
1366 | 1360 | | |
1367 | 1361 | | |
1368 | 1362 | | |
| |||
1409 | 1403 | | |
1410 | 1404 | | |
1411 | 1405 | | |
1412 | | - | |
| 1406 | + | |
1413 | 1407 | | |
1414 | 1408 | | |
1415 | 1409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
0 commit comments