diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-10-22 12:58:07 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-10-22 15:04:43 -0700 |
commit | 74163ea677b6daf129b8bc03f8a9058a77ef3702 (patch) | |
tree | 1777f8dcb9c4bc507a86f13476d4717223833a7f /gl/modules | |
parent | 565dd395c3ebbab4e8a4ceb47932814c693ed637 (diff) | |
download | coreutils-74163ea677b6daf129b8bc03f8a9058a77ef3702.tar.gz |
shuf: improve randperm overflow checking
* gl/lib/randperm.c: Include randperm.h first, since it’s the API.
Include stdint.h, count-leading-zeros.h, verify.h.
(floor_lg): Rename from ceil_log (which was not actually
implementing the ceiling!) and implement the floor using
count_leading_zeros.
(randperm_bound): Use floor_lg, not ceil_log. Use uintmax_t
instead of size_t in case the size gets large on a 32-bit host.
* gl/modules/randperm (Depends-on): Add count-leading-zeros, stdint.
Diffstat (limited to 'gl/modules')
-rw-r--r-- | gl/modules/randperm | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/gl/modules/randperm b/gl/modules/randperm index 1fa261290..e3b347140 100644 --- a/gl/modules/randperm +++ b/gl/modules/randperm @@ -6,7 +6,9 @@ lib/randperm.c lib/randperm.h Depends-on: +count-leading-zeros randint +stdint xalloc hash |