From: Clinton Bunch <cdb_zsh@zentaur.org>
To: zsh-workers@zsh.org
Subject: Re: [PATCH 1/1] zsh/random
Date: Sat, 31 Aug 2024 09:10:12 -0500 [thread overview]
Message-ID: <6a3ecdb5-9005-43b8-bdf8-e36c621619a1@zentaur.org> (raw)
In-Reply-To: <9404-1725109014.214095@d2Zo.FvkO.Aqwb>
On 8/31/2024 07:56, Oliver Kiddle wrote:
> Clinton Bunch wrote:
>> I've made the recommended changes and removed the test file as the statistical
>> analysis proved to be flawed, and I can think of no other test.
> Thanks. I've now applied the change. Thanks for being patient with us
> and I'm sorry that reviews and feedback have dragged on.
>
> My test build does now include the following message:
>
> Including file Zsh/mod_random.yo
> mod_random.yo:55: No macro: int(...)
>
> I'm guessing it needs LPAR() and RPAR() where zrand_int is documented.
>
> And with clang, I get a couple of new compiler warnings:
>
> random.c:65:13: warning: variable 'val' set but not used [-Wunused-but-set-variable]
> 65 | size_t val = 0;
> | ^
> random.c:66:14: warning: variable 'bufptr' set but not used [-Wunused-but-set-variable]
> 66 | uint8_t *bufptr = buf;
> | ^
>
> This is probably conditional on HAVE_ARC4RANDOM_BUF being defined.
>
> Oliver
Here's a patch for those issues.
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;
}
prev parent reply other threads:[~2024-08-31 14:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-27 19:31 Clinton Bunch
2024-06-17 14:43 ` Jun. T
2024-06-17 23:52 ` Clinton Bunch
2024-06-18 0:16 ` Clinton Bunch
2024-06-18 2:10 ` Clinton Bunch
2024-06-19 20:21 ` Bart Schaefer
2024-06-19 20:37 ` Clinton Bunch
2024-08-27 22:35 ` Oliver Kiddle
2024-08-30 13:06 ` Clinton Bunch
2024-08-31 12:56 ` Oliver Kiddle
2024-08-31 14:10 ` Clinton Bunch [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a3ecdb5-9005-43b8-bdf8-e36c621619a1@zentaur.org \
--to=cdb_zsh@zentaur.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).