diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2013-01-22 06:29:26 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2013-02-04 08:16:53 -0500 |
commit | 3e8afe35c36fa0e928e038667709966a71a9cfa5 (patch) | |
tree | b74592dd4ec5e9fdcb89abf82374ecd9cd2e89b8 /crypto/ccm.c | |
parent | 7b5c253c88ae5f6770e426b1d3f135be75483200 (diff) |
crypto: use ERR_CAST
Replace PTR_ERR followed by ERR_PTR by ERR_CAST, to be more concise.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression err,x;
@@
- err = PTR_ERR(x);
if (IS_ERR(x))
- return ERR_PTR(err);
+ return ERR_CAST(x);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ccm.c')
-rw-r--r-- | crypto/ccm.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/crypto/ccm.c b/crypto/ccm.c index 32fe1bb5decb..499c91717d93 100644 --- a/crypto/ccm.c +++ b/crypto/ccm.c | |||
@@ -484,18 +484,16 @@ static struct crypto_instance *crypto_ccm_alloc_common(struct rtattr **tb, | |||
484 | int err; | 484 | int err; |
485 | 485 | ||
486 | algt = crypto_get_attr_type(tb); | 486 | algt = crypto_get_attr_type(tb); |
487 | err = PTR_ERR(algt); | ||
488 | if (IS_ERR(algt)) | 487 | if (IS_ERR(algt)) |
489 | return ERR_PTR(err); | 488 | return ERR_CAST(algt); |
490 | 489 | ||
491 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 490 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
492 | return ERR_PTR(-EINVAL); | 491 | return ERR_PTR(-EINVAL); |
493 | 492 | ||
494 | cipher = crypto_alg_mod_lookup(cipher_name, CRYPTO_ALG_TYPE_CIPHER, | 493 | cipher = crypto_alg_mod_lookup(cipher_name, CRYPTO_ALG_TYPE_CIPHER, |
495 | CRYPTO_ALG_TYPE_MASK); | 494 | CRYPTO_ALG_TYPE_MASK); |
496 | err = PTR_ERR(cipher); | ||
497 | if (IS_ERR(cipher)) | 495 | if (IS_ERR(cipher)) |
498 | return ERR_PTR(err); | 496 | return ERR_CAST(cipher); |
499 | 497 | ||
500 | err = -EINVAL; | 498 | err = -EINVAL; |
501 | if (cipher->cra_blocksize != 16) | 499 | if (cipher->cra_blocksize != 16) |
@@ -573,15 +571,13 @@ out_put_cipher: | |||
573 | 571 | ||
574 | static struct crypto_instance *crypto_ccm_alloc(struct rtattr **tb) | 572 | static struct crypto_instance *crypto_ccm_alloc(struct rtattr **tb) |
575 | { | 573 | { |
576 | int err; | ||
577 | const char *cipher_name; | 574 | const char *cipher_name; |
578 | char ctr_name[CRYPTO_MAX_ALG_NAME]; | 575 | char ctr_name[CRYPTO_MAX_ALG_NAME]; |
579 | char full_name[CRYPTO_MAX_ALG_NAME]; | 576 | char full_name[CRYPTO_MAX_ALG_NAME]; |
580 | 577 | ||
581 | cipher_name = crypto_attr_alg_name(tb[1]); | 578 | cipher_name = crypto_attr_alg_name(tb[1]); |
582 | err = PTR_ERR(cipher_name); | ||
583 | if (IS_ERR(cipher_name)) | 579 | if (IS_ERR(cipher_name)) |
584 | return ERR_PTR(err); | 580 | return ERR_CAST(cipher_name); |
585 | 581 | ||
586 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", | 582 | if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", |
587 | cipher_name) >= CRYPTO_MAX_ALG_NAME) | 583 | cipher_name) >= CRYPTO_MAX_ALG_NAME) |
@@ -612,20 +608,17 @@ static struct crypto_template crypto_ccm_tmpl = { | |||
612 | 608 | ||
613 | static struct crypto_instance *crypto_ccm_base_alloc(struct rtattr **tb) | 609 | static struct crypto_instance *crypto_ccm_base_alloc(struct rtattr **tb) |
614 | { | 610 | { |
615 | int err; | ||
616 | const char *ctr_name; | 611 | const char *ctr_name; |
617 | const char *cipher_name; | 612 | const char *cipher_name; |
618 | char full_name[CRYPTO_MAX_ALG_NAME]; | 613 | char full_name[CRYPTO_MAX_ALG_NAME]; |
619 | 614 | ||
620 | ctr_name = crypto_attr_alg_name(tb[1]); | 615 | ctr_name = crypto_attr_alg_name(tb[1]); |
621 | err = PTR_ERR(ctr_name); | ||
622 | if (IS_ERR(ctr_name)) | 616 | if (IS_ERR(ctr_name)) |
623 | return ERR_PTR(err); | 617 | return ERR_CAST(ctr_name); |
624 | 618 | ||
625 | cipher_name = crypto_attr_alg_name(tb[2]); | 619 | cipher_name = crypto_attr_alg_name(tb[2]); |
626 | err = PTR_ERR(cipher_name); | ||
627 | if (IS_ERR(cipher_name)) | 620 | if (IS_ERR(cipher_name)) |
628 | return ERR_PTR(err); | 621 | return ERR_CAST(cipher_name); |
629 | 622 | ||
630 | if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm_base(%s,%s)", | 623 | if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "ccm_base(%s,%s)", |
631 | ctr_name, cipher_name) >= CRYPTO_MAX_ALG_NAME) | 624 | ctr_name, cipher_name) >= CRYPTO_MAX_ALG_NAME) |
@@ -760,17 +753,15 @@ static struct crypto_instance *crypto_rfc4309_alloc(struct rtattr **tb) | |||
760 | int err; | 753 | int err; |
761 | 754 | ||
762 | algt = crypto_get_attr_type(tb); | 755 | algt = crypto_get_attr_type(tb); |
763 | err = PTR_ERR(algt); | ||
764 | if (IS_ERR(algt)) | 756 | if (IS_ERR(algt)) |
765 | return ERR_PTR(err); | 757 | return ERR_CAST(algt); |
766 | 758 | ||
767 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) | 759 | if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask) |
768 | return ERR_PTR(-EINVAL); | 760 | return ERR_PTR(-EINVAL); |
769 | 761 | ||
770 | ccm_name = crypto_attr_alg_name(tb[1]); | 762 | ccm_name = crypto_attr_alg_name(tb[1]); |
771 | err = PTR_ERR(ccm_name); | ||
772 | if (IS_ERR(ccm_name)) | 763 | if (IS_ERR(ccm_name)) |
773 | return ERR_PTR(err); | 764 | return ERR_CAST(ccm_name); |
774 | 765 | ||
775 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); | 766 | inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL); |
776 | if (!inst) | 767 | if (!inst) |