FreeBSD: fix compilation of FreeBSD world after 29274c9f6

prng32_bounded() is available to kernel only on FreeBSD 13+.

Call inline random_get_pseudo_bytes() with correct pointer type.
To be consistent, apply to Linux as well.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Martin Matuska <mm@FreeBSD.org>
Closes #12282
This commit is contained in:
Martin Matuška 2021-06-25 19:28:51 +02:00 committed by GitHub
parent 88a4833039
commit 14d2841b53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -51,7 +51,7 @@ random_get_pseudo_bytes(uint8_t *p, size_t s)
static inline uint32_t
random_in_range(uint32_t range)
{
#if __FreeBSD_version >= 1300108
#if defined(_KERNEL) && __FreeBSD_version >= 1300108
return (prng32_bounded(range));
#else
uint32_t r;
@ -61,7 +61,7 @@ random_in_range(uint32_t range)
if (range == 1)
return (0);
(void) random_get_pseudo_bytes((void *)&r, sizeof (r));
(void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r));
return (r % range);
#endif

View File

@ -46,7 +46,7 @@ random_in_range(uint32_t range)
if (range == 1)
return (0);
(void) random_get_pseudo_bytes((void *)&r, sizeof (r));
(void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r));
return (r % range);
}

View File

@ -648,7 +648,7 @@ random_in_range(uint32_t range)
if (range == 1)
return (0);
(void) random_get_pseudo_bytes((void *)&r, sizeof (r));
(void) random_get_pseudo_bytes((uint8_t *)&r, sizeof (r));
return (r % range);
}