aboutsummaryrefslogtreecommitdiff
path: root/games
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>2008-08-11 23:24:42 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>2008-08-11 23:24:42 +0000
commitd77b331074778d8a2aab9b362b1e4cd583aef4f3 (patch)
treedf8b2f870814f902229ceb8d2f2d9b94e108a7ac /games
parent9b4de886f9780a973727a4d46fbc21a9fa999398 (diff)
downloadsrc-d77b331074778d8a2aab9b362b1e4cd583aef4f3.tar.gz
src-d77b331074778d8a2aab9b362b1e4cd583aef4f3.zip
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
Notes
Notes: svn path=/head/; revision=181615
Diffstat (limited to 'games')
-rw-r--r--games/random/random.c3
-rw-r--r--games/random/randomize_fd.c13
2 files changed, 11 insertions, 5 deletions
diff --git a/games/random/random.c b/games/random/random.c
index 25803488de3e..c1be97ba5cb9 100644
--- a/games/random/random.c
+++ b/games/random/random.c
@@ -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))
diff --git a/games/random/randomize_fd.c b/games/random/randomize_fd.c
index 960c4b9ca1ae..94881f72de62 100644
--- a/games/random/randomize_fd.c
+++ b/games/random/randomize_fd.c
@@ -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");
}