summaryrefslogtreecommitdiffstats
path: root/games/random/random.c
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2008-08-10 11:31:56 +0000
committerache <ache@FreeBSD.org>2008-08-10 11:31:56 +0000
commit7b638af8acb02ec4fb6007a3c7959c076391077f (patch)
tree8a1d648a35d6dda07127031504887ace9b1b8231 /games/random/random.c
parent996d7f2ebc0cc8300f9e529343bab86cdee4c554 (diff)
downloadFreeBSD-src-7b638af8acb02ec4fb6007a3c7959c076391077f.zip
FreeBSD-src-7b638af8acb02ec4fb6007a3c7959c076391077f.tar.gz
All cosmetic.
1) Rename RANDOM_MAX to RANDOM_MAX_PLUS1 to not confuse with random()'s max 2) Use calloc() instead of zeroing fields explicitly 3) "too many lines" -> "too many delimiters" for err()
Diffstat (limited to 'games/random/random.c')
-rw-r--r--games/random/random.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/games/random/random.c b/games/random/random.c
index 122ce45..2580348 100644
--- a/games/random/random.c
+++ b/games/random/random.c
@@ -162,7 +162,7 @@ main(int argc, char *argv[])
/* Compute a random exit status between 0 and denom - 1. */
if (random_exit)
- return (int)(denom * random() / RANDOM_MAX);
+ return (int)(denom * random() / RANDOM_MAX_PLUS1);
/*
* Select whether to print the first line. (Prime the pump.)
@@ -170,7 +170,7 @@ main(int argc, char *argv[])
* 0 (which has a 1 / denom chance of being true), we select the
* line.
*/
- selected = (int)(denom * random() / RANDOM_MAX) == 0;
+ selected = (int)(denom * random() / RANDOM_MAX_PLUS1) == 0;
while ((ch = getchar()) != EOF) {
if (selected)
(void)putchar(ch);
@@ -180,7 +180,7 @@ main(int argc, char *argv[])
err(2, "stdout");
/* Now see if the next line is to be printed. */
- selected = (int)(denom * random() / RANDOM_MAX) == 0;
+ selected = (int)(denom * random() / RANDOM_MAX_PLUS1) == 0;
}
}
if (ferror(stdin))
OpenPOWER on IntegriCloud