Skip to content

Commit

Permalink
FreeBSD: fix compilation of FreeBSD world after 29274c9
Browse files Browse the repository at this point in the history
prng32_bounded() is availabe to kernel only on FreeBSD 13+.

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

Signed-off-by: Martin Matuska <mm@FreeBSD.org>
  • Loading branch information
mmatuska committed Jun 25, 2021
1 parent 88a4833 commit 5c9c353
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/os/freebsd/spl/sys/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/os/linux/spl/sys/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5c9c353

Please sign in to comment.