summaryrefslogtreecommitdiff
path: root/sys/crypto/crypto.c
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2006-05-31 23:01:45 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2006-05-31 23:01:45 +0000
commit14122972524e1f349a5da3b63d98f5edf53df290 (patch)
tree056d6b328edcc23eee6af6d66d220df5bc434f63 /sys/crypto/crypto.c
parentb6fd4a36bf93e9be4d0ac2d98b614c935ce50921 (diff)
remove some silly casts. put spl calls after all declarations.
put one splx in a better spot. make a variable size MALLOC use malloc. remove null test after malloc(M_WAITOK). add PR_NOWAIT flag to pool_get instead of 0. change callbacks to correct type. ok brad deraadt markus mickey
Diffstat (limited to 'sys/crypto/crypto.c')
-rw-r--r--sys/crypto/crypto.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c
index c410023523a..8f6327f8980 100644
--- a/sys/crypto/crypto.c
+++ b/sys/crypto/crypto.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: crypto.c,v 1.47 2006/03/04 21:33:39 brad Exp $ */
+/* $OpenBSD: crypto.c,v 1.48 2006/05/31 23:01:44 tedu Exp $ */
/*
* The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu)
*
@@ -216,15 +216,17 @@ int32_t
crypto_get_driverid(u_int8_t flags)
{
struct cryptocap *newdrv;
- int i, s = splvm();
+ int i, s;
+
+ s = splvm();
if (crypto_drivers_num == 0) {
crypto_drivers_num = CRYPTO_DRIVERS_INITIAL;
crypto_drivers = malloc(crypto_drivers_num *
sizeof(struct cryptocap), M_CRYPTO_DATA, M_NOWAIT);
if (crypto_drivers == NULL) {
- splx(s);
crypto_drivers_num = 0;
+ splx(s);
return -1;
}
@@ -355,9 +357,11 @@ crypto_register(u_int32_t driverid, int *alg,
int
crypto_unregister(u_int32_t driverid, int alg)
{
- int i = CRYPTO_ALGORITHM_MAX + 1, s = splvm();
+ int i = CRYPTO_ALGORITHM_MAX + 1, s;
u_int32_t ses;
+ s = splvm();
+
/* Sanity checks. */
if (driverid >= crypto_drivers_num || crypto_drivers == NULL ||
((alg <= 0 || alg > CRYPTO_ALGORITHM_MAX) &&
@@ -401,9 +405,10 @@ crypto_unregister(u_int32_t driverid, int alg)
int
crypto_dispatch(struct cryptop *crp)
{
- int s = splvm();
+ int s;
u_int32_t hid;
+ s = splvm();
/*
* Keep track of ops per driver, for coallescing purposes. If
* we have been given an invalid hid, we'll deal with in the
@@ -418,7 +423,7 @@ crypto_dispatch(struct cryptop *crp)
crp_req_queue = crp;
crp_req_queue_tail = &(crp->crp_next);
splx(s);
- wakeup((caddr_t) &crp_req_queue); /* Shared wait channel. */
+ wakeup(&crp_req_queue); /* Shared wait channel. */
} else {
*crp_req_queue_tail = crp;
crp_req_queue_tail = &(crp->crp_next);
@@ -430,14 +435,16 @@ crypto_dispatch(struct cryptop *crp)
int
crypto_kdispatch(struct cryptkop *krp)
{
- int s = splvm();
+ int s;
+
+ s = splvm();
krp->krp_next = NULL;
if (krp_req_queue == NULL) {
krp_req_queue = krp;
krp_req_queue_tail = &(krp->krp_next);
splx(s);
- wakeup((caddr_t) &crp_req_queue); /* Shared wait channel. */
+ wakeup(&crp_req_queue); /* Shared wait channel. */
} else {
*krp_req_queue_tail = krp;
krp_req_queue_tail = &(krp->krp_next);
@@ -586,7 +593,9 @@ crypto_getreq(int num)
{
struct cryptodesc *crd;
struct cryptop *crp;
- int s = splvm();
+ int s;
+
+ s = splvm();
if (crypto_pool_initialized == 0) {
pool_init(&cryptop_pool, sizeof(struct cryptop), 0, 0,
@@ -596,7 +605,7 @@ crypto_getreq(int num)
crypto_pool_initialized = 1;
}
- crp = pool_get(&cryptop_pool, 0);
+ crp = pool_get(&cryptop_pool, PR_NOWAIT);
if (crp == NULL) {
splx(s);
return NULL;
@@ -604,7 +613,7 @@ crypto_getreq(int num)
bzero(crp, sizeof(struct cryptop));
while (num--) {
- crd = pool_get(&cryptodesc_pool, 0);
+ crd = pool_get(&cryptodesc_pool, PR_NOWAIT);
if (crd == NULL) {
splx(s);
crypto_freereq(crp);
@@ -636,7 +645,7 @@ crypto_thread(void)
crp = crp_req_queue;
krp = krp_req_queue;
if (crp == NULL && krp == NULL) {
- (void) tsleep(&crp_req_queue, PLOCK, "crypto_wait", 0);
+ (void)tsleep(&crp_req_queue, PLOCK, "crypto_wait", 0);
continue;
}