From 6b9704e2c4e4c8524137a9c15bf9b166a975f3eb Mon Sep 17 00:00:00 2001 From: Clinton Bunch Date: Sat, 31 Aug 2024 09:10:12 -0500 Subject: [PATCH] 53060: silence build warnings --- ChangeLog | 3 +++ Doc/Zsh/mod_random.yo | 2 +- Src/Modules/random.c | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 51a859143..7e181e959 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2024-08-31 Oliver Kiddle + * Clinton Bunch: 53060: Doc/Zsh/mod_random.yo, + Src/Modules/random.c: silence build warnings + * Clinton Bunch: 53056: Completion/Zsh/Type/_module_math_func, Doc/Makefile.in, Doc/Zsh/mod_random.yo, Src/Modules/random.c, Src/Modules/random.mdd, Src/Modules/random_real.c, configure.ac: diff --git a/Doc/Zsh/mod_random.yo b/Doc/Zsh/mod_random.yo index d2892bf79..4f5622e61 100644 --- a/Doc/Zsh/mod_random.yo +++ b/Doc/Zsh/mod_random.yo @@ -41,7 +41,7 @@ tt(inclusive) is a flag that controls whether the result is ever equal to tt(upper). By default it is not. If this argument is set to a non-zero value then it may be. -This is to facilitate a construct like tt($a[zrand_int($#a)+1]) rather +This is to facilitate a construct like tt($a[zrand_int+LPAR()$#a+RPAR()+1]) rather than tt($a[zrand_int+LPAR()$#a-1+RPAR()+1]). For example, if $#a is 16, you would use tt(zrand_int+LPAR()16RPAR()) which has 16 possible return values 0-15. Because the function can return zero, in order diff --git a/Src/Modules/random.c b/Src/Modules/random.c index a153d8f64..88ac9543c 100644 --- a/Src/Modules/random.c +++ b/Src/Modules/random.c @@ -62,8 +62,10 @@ ssize_t getrandom_buffer(void *buf, size_t len) { ssize_t ret; +#ifndef HAVE_ARC4RANDOM_BUF size_t val = 0; uint8_t *bufptr = buf; +#endif do { errno = 0; @@ -81,8 +83,10 @@ getrandom_buffer(void *buf, size_t len) return -1; } } +#ifndef HAVE_ARC4RANDOM_BUF bufptr += ret; val += ret; +#endif } while (ret < len); return ret; }