Module Name: src
Committed By: riastradh
Date: Tue Feb 25 23:15:43 UTC 2014
Modified Files:
src/sys/kern: kern_rndq.c
Log Message:
Fix bits/bytes mixup in rnd_getmore.
Remove some needless casts and fix format directives while here.
Bit/byte mixup noticed by pooka.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/kern/kern_rndq.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/kern_rndq.c
diff -u src/sys/kern/kern_rndq.c:1.21 src/sys/kern/kern_rndq.c:1.22
--- src/sys/kern/kern_rndq.c:1.21 Thu Aug 29 01:04:49 2013
+++ src/sys/kern/kern_rndq.c Tue Feb 25 23:15:43 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rndq.c,v 1.21 2013/08/29 01:04:49 tls Exp $ */
+/* $NetBSD: kern_rndq.c,v 1.22 2014/02/25 23:15:43 riastradh Exp $ */
/*-
* Copyright (c) 1997-2013 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.21 2013/08/29 01:04:49 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rndq.c,v 1.22 2014/02/25 23:15:43 riastradh Exp $");
#include <sys/param.h>
#include <sys/ioctl.h>
@@ -241,10 +241,10 @@ rnd_getmore(size_t byteswanted)
if (rs->flags & RND_FLAG_HASCB) {
KASSERT(rs->get != NULL);
KASSERT(rs->getarg != NULL);
- rs->get((size_t)byteswanted, rs->getarg);
+ rs->get(byteswanted, rs->getarg);
#ifdef RND_VERBOSE
- printf("rnd: asking source %s for %d bytes\n",
- rs->name, (int)byteswanted);
+ printf("rnd: asking source %s for %zu bytes\n",
+ rs->name, byteswanted);
#endif
}
}
@@ -868,14 +868,14 @@ rnd_process_events(void)
mutex_spin_enter(&rndpool_mtx);
pool_entropy = rndpool_get_entropy_count(&rnd_pool);
- if (pool_entropy > RND_ENTROPY_THRESHOLD * 8) {
+ if (pool_entropy > RND_ENTROPY_THRESHOLD * NBBY) {
wake++;
} else {
rnd_empty = 1;
- rnd_getmore((RND_POOLBITS - pool_entropy) / 8);
+ rnd_getmore(howmany((RND_POOLBITS - pool_entropy), NBBY));
#ifdef RND_VERBOSE
- printf("rnd: empty, asking for %d bits\n",
- (int)((RND_POOLBITS - pool_entropy) / 8));
+ printf("rnd: empty, asking for %zu bytes\n",
+ howmany((RND_POOLBITS - pool_entropy), NBBY));
#endif
}
@@ -1032,8 +1032,8 @@ rnd_extract_data_locked(void *p, u_int32
}
#endif
entropy_count = rndpool_get_entropy_count(&rnd_pool);
- if (entropy_count < (RND_ENTROPY_THRESHOLD * 2 + len) * 8) {
- rnd_getmore(RND_POOLBITS - entropy_count * 8);
+ if (entropy_count < (RND_ENTROPY_THRESHOLD * 2 + len) * NBBY) {
+ rnd_getmore(howmany((RND_POOLBITS - entropy_count), NBBY));
}
return rndpool_extract_data(&rnd_pool, p, len, flags);
}