mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 04:33:26 +02:00
treewide: use get_random_u32_inclusive() when possible
These cases were done with this Coccinelle: @@ expression H; expression L; @@ - (get_random_u32_below(H) + L) + get_random_u32_inclusive(L, H + L - 1) @@ expression H; expression L; expression E; @@ get_random_u32_inclusive(L, H - + E - - E ) @@ expression H; expression L; expression E; @@ get_random_u32_inclusive(L, H - - E - + E ) @@ expression H; expression L; expression E; expression F; @@ get_random_u32_inclusive(L, H - - E + F - + E ) @@ expression H; expression L; expression E; expression F; @@ get_random_u32_inclusive(L, H - + E + F - - E ) And then subsequently cleaned up by hand, with several automatic cases rejected if it didn't make sense contextually. Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> # for infiniband Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -151,7 +151,7 @@ static int random_size_alloc_test(void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < test_loop_count; i++) {
|
||||
n = get_random_u32_below(100) + 1;
|
||||
n = get_random_u32_inclusive(1, 100);
|
||||
p = vmalloc(n * PAGE_SIZE);
|
||||
|
||||
if (!p)
|
||||
@@ -291,12 +291,12 @@ pcpu_alloc_test(void)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < 35000; i++) {
|
||||
size = get_random_u32_below(PAGE_SIZE / 4) + 1;
|
||||
size = get_random_u32_inclusive(1, PAGE_SIZE / 4);
|
||||
|
||||
/*
|
||||
* Maximum PAGE_SIZE
|
||||
*/
|
||||
align = 1 << (get_random_u32_below(11) + 1);
|
||||
align = 1 << get_random_u32_inclusive(1, 11);
|
||||
|
||||
pcpu[i] = __alloc_percpu(size, align);
|
||||
if (!pcpu[i])
|
||||
|
Reference in New Issue
Block a user