diff options
author | Martin Matuška <mm@FreeBSD.org> | 2021-06-25 17:28:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-25 17:28:51 +0000 |
commit | 14d2841b5318f92bc443d24ed65f29ccc4b9f2bd (patch) | |
tree | bfc44cbc5da18ecbfd8b3d63e055513f82106b42 | |
parent | 88a4833039b4a3f08139c5b69a2300424fddfd0f (diff) | |
download | src-14d2841b5318f92bc443d24ed65f29ccc4b9f2bd.tar.gz src-14d2841b5318f92bc443d24ed65f29ccc4b9f2bd.zip |
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
-rw-r--r-- | include/os/freebsd/spl/sys/random.h | 4 | ||||
-rw-r--r-- | include/os/linux/spl/sys/random.h | 2 | ||||
-rw-r--r-- | include/sys/zfs_context.h | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/include/os/freebsd/spl/sys/random.h b/include/os/freebsd/spl/sys/random.h index 746275e53197..7583166e727b 100644 --- a/include/os/freebsd/spl/sys/random.h +++ b/include/os/freebsd/spl/sys/random.h @@ -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 diff --git a/include/os/linux/spl/sys/random.h b/include/os/linux/spl/sys/random.h index 2c446e155761..52e97e1ce068 100644 --- a/include/os/linux/spl/sys/random.h +++ b/include/os/linux/spl/sys/random.h @@ -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); } diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index d20efa02af32..4d67e652ab62 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -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); } |