[PATCH 3/8] crypto: AF_ALG - eliminate code duplication

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The handling function for setsockopt contains duplicated code which is
cleaned up with this patch. This patch does not change the functionality.

Signed-off-by: Stephan Mueller <smueller@xxxxxxxxxx>
---
 crypto/af_alg.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index a3210bf..f2b2865 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -247,34 +247,23 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
 	if (level != SOL_ALG || !type)
 		goto unlock;
 
+	if (sock->state == SS_CONNECTED)
+		goto unlock;
+
 	switch (optname) {
 	case ALG_SET_KEY:
-		if (sock->state == SS_CONNECTED)
-			goto unlock;
-
 		err = alg_setkey(sk, optval, optlen, type->setkey);
 		break;
 	case ALG_SET_PUBKEY:
-		if (sock->state == SS_CONNECTED)
-			goto unlock;
-
 		err = alg_setkey(sk, optval, optlen, type->setpubkey);
 		break;
 	case ALG_SET_DH_PARAMETERS:
-		if (sock->state == SS_CONNECTED)
-			goto unlock;
-
 		err = alg_setkey(sk, optval, optlen, type->dhparams);
 		break;
 	case ALG_SET_ECDH_CURVE:
-		if (sock->state == SS_CONNECTED)
-			goto unlock;
-
 		err = alg_setkey(sk, optval, optlen, type->ecdhcurve);
 		break;
 	case ALG_SET_AEAD_AUTHSIZE:
-		if (sock->state == SS_CONNECTED)
-			goto unlock;
 		if (!type->setauthsize)
 			goto unlock;
 		err = type->setauthsize(ask->private, optlen);
-- 
2.9.3





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux