static void
fillrand (struct isaac_state *s, uint32_t *r, size_t size_max, size_t size)
{
- size = (size + ISAAC_BYTES - 1) / ISAAC_BYTES;
- assert (size <= size_max);
+ size_t refills = (size + ISAAC_BYTES - 1) / ISAAC_BYTES;
+ assert (refills * ISAAC_BYTES <= size_max);
- while (size--)
+ while (refills--)
{
isaac_refill (s, r);
r += ISAAC_WORDS;
size_t lim; /* Amount of data to try writing */
size_t soff; /* Offset into buffer for next write */
ssize_t ssize; /* Return value from write */
- uint32_t *r; /* Fill pattern. */
- size_t rsize = 3 * MAX (ISAAC_WORDS, 1024) * sizeof *r; /* Fill size. */
- size_t ralign = lcm (getpagesize (), sizeof *r); /* Fill alignment. */
+ uint32_t r[3 * MAX (ISAAC_WORDS, 1024)]; /* Fill pattern. */
char pass_string[PASS_NAME_SIZE]; /* Name of current pass */
bool write_error = false;
bool first_write = true;
return -1;
}
- r = alloca (rsize + ralign - 1);
- r = ptr_align (r, ralign);
-
/* Constant fill patterns need only be set up once. */
if (type >= 0)
{
- lim = rsize;
+ lim = sizeof r;
if ((off_t) lim > size && size != -1)
{
lim = (size_t) size;
for (;;)
{
/* How much to write this time? */
- lim = rsize;
+ lim = sizeof r;
if ((off_t) lim > size - offset && size != -1)
{
if (size < offset)
break;
}
if (type < 0)
- fillrand (s, r, rsize, lim);
+ fillrand (s, r, sizeof r, lim);
/* Loop to retry partial writes. */
for (soff = 0; soff < lim; soff += ssize, first_write = false)
{