1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-27 08:00:11 +00:00

Suggections from bde@

1) Split too long source lines
2) Portable code should not assume that null pointer == all-bits-0,
so back out prev. calloc() change.

Submitted by:   bde
This commit is contained in:
Andrey A. Chernov 2008-08-11 23:24:42 +00:00
parent 9b4de886f9
commit d77b331074
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181615
2 changed files with 11 additions and 5 deletions

View File

@ -180,7 +180,8 @@ main(int argc, char *argv[])
err(2, "stdout");
/* Now see if the next line is to be printed. */
selected = (int)(denom * random() / RANDOM_MAX_PLUS1) == 0;
selected = (int)(denom * random() /
RANDOM_MAX_PLUS1) == 0;
}
}
if (ferror(stdin))

View File

@ -48,10 +48,13 @@ rand_node_allocate(void)
{
struct rand_node *n;
n = (struct rand_node *)calloc(1, sizeof(struct rand_node));
n = (struct rand_node *)malloc(sizeof(struct rand_node));
if (n == NULL)
err(1, "calloc");
err(1, "malloc");
n->len = 0;
n->cp = NULL;
n->next = NULL;
return(n);
}
@ -212,8 +215,10 @@ randomize_fd(int fd, int type, int unique, double denom)
if (n->cp == NULL)
break;
if ((int)(denom * random() / RANDOM_MAX_PLUS1) == 0) {
ret = printf("%.*s", (int)n->len - 1, n->cp);
if ((int)(denom * random() /
RANDOM_MAX_PLUS1) == 0) {
ret = printf("%.*s",
(int)n->len - 1, n->cp);
if (ret < 0)
err(1, "printf");
}