Jason A. Donenfeld e8a533cbeb 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>
2022-11-18 02:18:02 +01:00
..
2020-08-28 16:58:28 +10:00
2022-03-03 10:49:20 +12:00
2021-03-26 19:55:55 +11:00
2022-06-10 16:40:17 +08:00
2022-08-02 17:14:47 -06:00
2022-02-18 16:21:08 +11:00
2020-02-28 08:43:21 +08:00
2022-08-02 17:14:47 -06:00
2021-08-21 15:44:58 +08:00
2022-04-08 16:12:46 +08:00
2022-06-10 16:40:16 +08:00
2022-02-18 16:21:08 +11:00
2021-11-08 16:55:21 -08:00