cleanups spotted by irix cc
This commit is contained in:
13
kern/posix.c
13
kern/posix.c
@ -126,6 +126,7 @@ tramp(void *vp)
|
||||
/* BUG: leaks Proc */
|
||||
pthread_setspecific(prdakey, 0);
|
||||
pthread_exit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
@ -161,20 +162,32 @@ int randfd;
|
||||
void
|
||||
randominit(void)
|
||||
{
|
||||
#ifdef USE_RANDOM
|
||||
srandom(getpid()+fastticks(nil)+ticks());
|
||||
#else
|
||||
if((randfd = open("/dev/urandom", OREAD)) < 0)
|
||||
if((randfd = open("/dev/random", OREAD)) < 0)
|
||||
panic("open /dev/random: %r");
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef read
|
||||
ulong
|
||||
randomread(void *v, ulong n)
|
||||
{
|
||||
#ifdef USE_RANDOM
|
||||
int i;
|
||||
|
||||
for(i=0; i<n; i++)
|
||||
((uchar*)v)[i] = random();
|
||||
return n;
|
||||
#else
|
||||
int m;
|
||||
|
||||
if((m = read(randfd, v, n)) != n)
|
||||
panic("short read from /dev/random: %d but %d", n, m);
|
||||
return m;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef time
|
||||
|
Reference in New Issue
Block a user