From: bluhm Date: Wed, 13 Oct 2021 22:43:44 +0000 (+0000) Subject: The function crypto_dispatch() never returns an error. Make it X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b092f79b148ca03a2fd0826af66ba0b99bdc2075;p=openbsd The function crypto_dispatch() never returns an error. Make it void and remove error handling in the callers. OK patrick@ mvs@ --- diff --git a/sys/crypto/crypto.c b/sys/crypto/crypto.c index a278f305ea3..dc613267ed6 100644 --- a/sys/crypto/crypto.c +++ b/sys/crypto/crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto.c,v 1.86 2021/10/13 13:08:58 bluhm Exp $ */ +/* $OpenBSD: crypto.c,v 1.87 2021/10/13 22:43:44 bluhm Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -384,10 +384,10 @@ crypto_unregister(u_int32_t driverid, int alg) /* * Add crypto request to a queue, to be processed by a kernel thread. */ -int +void crypto_dispatch(struct cryptop *crp) { - int error = 0, lock = 1, s; + int lock = 1, s; u_int32_t hid; s = splvm(); @@ -414,8 +414,6 @@ crypto_dispatch(struct cryptop *crp) task_set(&crp->crp_task, (void (*))crypto_invoke, crp); task_add(tq, &crp->crp_task); } - - return error; } /* diff --git a/sys/crypto/cryptodev.h b/sys/crypto/cryptodev.h index 699074db83f..86b5d93509c 100644 --- a/sys/crypto/cryptodev.h +++ b/sys/crypto/cryptodev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cryptodev.h,v 1.75 2021/10/13 13:08:58 bluhm Exp $ */ +/* $OpenBSD: cryptodev.h,v 1.76 2021/10/13 22:43:44 bluhm Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) @@ -218,7 +218,7 @@ void crypto_init(void); int crypto_newsession(u_int64_t *, struct cryptoini *, int); int crypto_freesession(u_int64_t); -int crypto_dispatch(struct cryptop *); +void crypto_dispatch(struct cryptop *); int crypto_register(u_int32_t, int *, int (*)(u_int32_t *, struct cryptoini *), int (*)(u_int64_t), int (*)(struct cryptop *)); diff --git a/sys/dev/softraid_crypto.c b/sys/dev/softraid_crypto.c index ace87488e8c..ceed940f874 100644 --- a/sys/dev/softraid_crypto.c +++ b/sys/dev/softraid_crypto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_crypto.c,v 1.141 2021/05/10 08:17:07 stsp Exp $ */ +/* $OpenBSD: softraid_crypto.c,v 1.142 2021/10/13 22:43:44 bluhm Exp $ */ /* * Copyright (c) 2007 Marco Peereboom * Copyright (c) 2008 Hans-Joerg Hoexer @@ -1157,7 +1157,7 @@ sr_crypto_rw(struct sr_workunit *wu) struct sr_crypto_wu *crwu; struct sr_crypto *mdd_crypto; daddr_t blkno; - int rv = 0; + int rv; DNPRINTF(SR_D_DIS, "%s: sr_crypto_rw wu %p\n", DEVNAME(wu->swu_dis->sd_sc), wu); @@ -1169,9 +1169,8 @@ sr_crypto_rw(struct sr_workunit *wu) mdd_crypto = &wu->swu_dis->mds.mdd_crypto; crwu = sr_crypto_prepare(wu, mdd_crypto, 1); crwu->cr_crp->crp_callback = sr_crypto_write; - rv = crypto_dispatch(crwu->cr_crp); - if (rv == 0) - rv = crwu->cr_crp->crp_etype; + crypto_dispatch(crwu->cr_crp); + rv = crwu->cr_crp->crp_etype; } else rv = sr_crypto_dev_rw(wu, NULL); diff --git a/sys/dev/softraid_raid1c.c b/sys/dev/softraid_raid1c.c index 4be4030f84a..d23323bc5e4 100644 --- a/sys/dev/softraid_raid1c.c +++ b/sys/dev/softraid_raid1c.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_raid1c.c,v 1.3 2021/05/10 08:17:07 stsp Exp $ */ +/* $OpenBSD: softraid_raid1c.c,v 1.4 2021/10/13 22:43:44 bluhm Exp $ */ /* * Copyright (c) 2007 Marco Peereboom * Copyright (c) 2008 Hans-Joerg Hoexer @@ -346,7 +346,7 @@ sr_raid1c_rw(struct sr_workunit *wu) struct sr_crypto_wu *crwu; struct sr_raid1c *mdd_raid1c; daddr_t blkno; - int rv = 0; + int rv; DNPRINTF(SR_D_DIS, "%s: sr_raid1c_rw wu %p\n", DEVNAME(wu->swu_dis->sd_sc), wu); @@ -359,9 +359,8 @@ sr_raid1c_rw(struct sr_workunit *wu) mdd_raid1c = &wu->swu_dis->mds.mdd_raid1c; crwu = sr_crypto_prepare(wu, &mdd_raid1c->sr1c_crypto, 1); crwu->cr_crp->crp_callback = sr_raid1c_write; - rv = crypto_dispatch(crwu->cr_crp); - if (rv == 0) - rv = crwu->cr_crp->crp_etype; + crypto_dispatch(crwu->cr_crp); + rv = crwu->cr_crp->crp_etype; } else rv = sr_raid1c_dev_rw(wu, NULL); diff --git a/sys/netinet/ip_ah.c b/sys/netinet/ip_ah.c index 24bc3df1345..050d0e634d9 100644 --- a/sys/netinet/ip_ah.c +++ b/sys/netinet/ip_ah.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ah.c,v 1.155 2021/10/13 14:36:31 bluhm Exp $ */ +/* $OpenBSD: ip_ah.c,v 1.156 2021/10/13 22:43:44 bluhm Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -699,8 +699,8 @@ ah_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) memcpy(&tc->tc_dst, &tdb->tdb_dst, sizeof(union sockaddr_union)); tc->tc_rpl = tdb->tdb_rpl; - error = crypto_dispatch(crp); - return error; + crypto_dispatch(crp); + return 0; drop: m_freem(m); @@ -1145,8 +1145,8 @@ ah_output(struct mbuf *m, struct tdb *tdb, int skip, int protoff) tc->tc_rdomain = tdb->tdb_rdomain; memcpy(&tc->tc_dst, &tdb->tdb_dst, sizeof(union sockaddr_union)); - error = crypto_dispatch(crp); - return error; + crypto_dispatch(crp); + return 0; drop: m_freem(m); diff --git a/sys/netinet/ip_esp.c b/sys/netinet/ip_esp.c index 352b71d0b5d..eec2887f222 100644 --- a/sys/netinet/ip_esp.c +++ b/sys/netinet/ip_esp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_esp.c,v 1.173 2021/10/13 14:36:31 bluhm Exp $ */ +/* $OpenBSD: ip_esp.c,v 1.174 2021/10/13 22:43:44 bluhm Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -528,8 +528,8 @@ esp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) crde->crd_len = m->m_pkthdr.len - (skip + hlen + alen); } - error = crypto_dispatch(crp); - return error; + crypto_dispatch(crp); + return 0; drop: m_freem(m); @@ -1012,8 +1012,8 @@ esp_output(struct mbuf *m, struct tdb *tdb, int skip, int protoff) crda->crd_len = m->m_pkthdr.len - (skip + alen); } - error = crypto_dispatch(crp); - return error; + crypto_dispatch(crp); + return 0; drop: m_freem(m); diff --git a/sys/netinet/ip_ipcomp.c b/sys/netinet/ip_ipcomp.c index 1e639ab7de4..124a095e6d5 100644 --- a/sys/netinet/ip_ipcomp.c +++ b/sys/netinet/ip_ipcomp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipcomp.c,v 1.75 2021/10/13 14:36:31 bluhm Exp $ */ +/* $OpenBSD: ip_ipcomp.c,v 1.76 2021/10/13 22:43:44 bluhm Exp $ */ /* * Copyright (c) 2001 Jean-Jacques Bernard-Gundol (jj@wabbitt.org) @@ -139,7 +139,7 @@ ipcomp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) { const struct comp_algo *ipcompx = tdb->tdb_compalgxform; struct tdb_crypto *tc; - int hlen, error; + int hlen; struct cryptodesc *crdc = NULL; struct cryptop *crp; @@ -188,8 +188,8 @@ ipcomp_input(struct mbuf *m, struct tdb *tdb, int skip, int protoff) tc->tc_rdomain = tdb->tdb_rdomain; tc->tc_dst = tdb->tdb_dst; - error = crypto_dispatch(crp); - return error; + crypto_dispatch(crp); + return 0; } int @@ -482,8 +482,8 @@ ipcomp_output(struct mbuf *m, struct tdb *tdb, int skip, int protoff) crp->crp_opaque = (caddr_t)tc; crp->crp_sid = tdb->tdb_cryptoid; - error = crypto_dispatch(crp); - return error; + crypto_dispatch(crp); + return 0; drop: m_freem(m); diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c index 815a20893d9..67f94919bc1 100644 --- a/sys/netinet/ipsec_input.c +++ b/sys/netinet/ipsec_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec_input.c,v 1.182 2021/10/05 11:45:26 bluhm Exp $ */ +/* $OpenBSD: ipsec_input.c,v 1.183 2021/10/13 22:43:44 bluhm Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -401,11 +401,7 @@ ipsec_input_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - error = crypto_dispatch(crp); - if (error) { - DPRINTF("crypto dispatch error %d", error); - goto drop; - } + crypto_dispatch(crp); return; } DPRINTF("crypto error %d", crp->crp_etype); diff --git a/sys/netinet/ipsec_output.c b/sys/netinet/ipsec_output.c index bb9b7488883..dcde98fc5d8 100644 --- a/sys/netinet/ipsec_output.c +++ b/sys/netinet/ipsec_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec_output.c,v 1.88 2021/10/13 14:36:31 bluhm Exp $ */ +/* $OpenBSD: ipsec_output.c,v 1.89 2021/10/13 22:43:44 bluhm Exp $ */ /* * The author of this code is Angelos D. Keromytis (angelos@cis.upenn.edu) * @@ -409,11 +409,7 @@ ipsec_output_cb(struct cryptop *crp) /* Reset the session ID */ if (tdb->tdb_cryptoid != 0) tdb->tdb_cryptoid = crp->crp_sid; - error = crypto_dispatch(crp); - if (error) { - DPRINTF("crypto dispatch error %d", error); - goto drop; - } + crypto_dispatch(crp); return; } DPRINTF("crypto error %d", crp->crp_etype);