diff options
author | millert <> | 1998-02-07 02:16:25 +0000 |
---|---|---|
committer | millert <> | 1998-02-07 02:16:25 +0000 |
commit | a6240e129a714de0ec5e5cbc8421465926528d9e (patch) | |
tree | 28fb4f77ad25b8c8f7ebf4db8b5b2ab9fddc8aac /src/lib/libc/stdlib/random.c | |
parent | 3e1f199d9076db124c95fd0475b1ce73e079ac21 (diff) | |
download | openbsd-a6240e129a714de0ec5e5cbc8421465926528d9e.tar.gz openbsd-a6240e129a714de0ec5e5cbc8421465926528d9e.tar.bz2 openbsd-a6240e129a714de0ec5e5cbc8421465926528d9e.zip |
More XPG4.2 --
setstate takes a const parameter
don't ever spew to stderr, just return NULL
Diffstat (limited to 'src/lib/libc/stdlib/random.c')
-rw-r--r-- | src/lib/libc/stdlib/random.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c index 1ac61f2cec..79344f30f1 100644 --- a/src/lib/libc/stdlib/random.c +++ b/src/lib/libc/stdlib/random.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #if defined(LIBC_SCCS) && !defined(lint) | 34 | #if defined(LIBC_SCCS) && !defined(lint) |
35 | static char *rcsid = "$OpenBSD: random.c,v 1.5 1998/02/06 01:49:08 deraadt Exp $"; | 35 | static char *rcsid = "$OpenBSD: random.c,v 1.6 1998/02/07 02:16:25 millert Exp $"; |
36 | #endif /* LIBC_SCCS and not lint */ | 36 | #endif /* LIBC_SCCS and not lint */ |
37 | 37 | ||
38 | #include <stdio.h> | 38 | #include <stdio.h> |
@@ -250,11 +250,8 @@ initstate(seed, arg_state, n) | |||
250 | state[-1] = rand_type; | 250 | state[-1] = rand_type; |
251 | else | 251 | else |
252 | state[-1] = MAX_TYPES * (rptr - state) + rand_type; | 252 | state[-1] = MAX_TYPES * (rptr - state) + rand_type; |
253 | if (n < BREAK_0) { | 253 | if (n < BREAK_0) |
254 | (void)fprintf(stderr, | 254 | return(NULL); |
255 | "random: not enough state (%d bytes); ignored.\n", n); | ||
256 | return(0); | ||
257 | } | ||
258 | if (n < BREAK_1) { | 255 | if (n < BREAK_1) { |
259 | rand_type = TYPE_0; | 256 | rand_type = TYPE_0; |
260 | rand_deg = DEG_0; | 257 | rand_deg = DEG_0; |
@@ -303,7 +300,7 @@ initstate(seed, arg_state, n) | |||
303 | */ | 300 | */ |
304 | char * | 301 | char * |
305 | setstate(arg_state) | 302 | setstate(arg_state) |
306 | char *arg_state; | 303 | const char *arg_state; |
307 | { | 304 | { |
308 | register long *new_state = (long *)arg_state; | 305 | register long *new_state = (long *)arg_state; |
309 | register int type = new_state[0] % MAX_TYPES; | 306 | register int type = new_state[0] % MAX_TYPES; |
@@ -325,8 +322,7 @@ setstate(arg_state) | |||
325 | rand_sep = seps[type]; | 322 | rand_sep = seps[type]; |
326 | break; | 323 | break; |
327 | default: | 324 | default: |
328 | (void)fprintf(stderr, | 325 | return(NULL); |
329 | "random: state info corrupted; not changed.\n"); | ||
330 | } | 326 | } |
331 | state = &new_state[1]; | 327 | state = &new_state[1]; |
332 | if (rand_type != TYPE_0) { | 328 | if (rand_type != TYPE_0) { |