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>
This commit is contained in:
29
crypto/gcm.c
29
crypto/gcm.c
@@ -701,9 +701,8 @@ static struct crypto_instance *crypto_gcm_alloc_common(struct rtattr **tb,
|
||||
int err;
|
||||
|
||||
algt = crypto_get_attr_type(tb);
|
||||
err = PTR_ERR(algt);
|
||||
if (IS_ERR(algt))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(algt);
|
||||
|
||||
if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
|
||||
return ERR_PTR(-EINVAL);
|
||||
@@ -711,9 +710,8 @@ static struct crypto_instance *crypto_gcm_alloc_common(struct rtattr **tb,
|
||||
ghash_alg = crypto_find_alg(ghash_name, &crypto_ahash_type,
|
||||
CRYPTO_ALG_TYPE_HASH,
|
||||
CRYPTO_ALG_TYPE_AHASH_MASK);
|
||||
err = PTR_ERR(ghash_alg);
|
||||
if (IS_ERR(ghash_alg))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(ghash_alg);
|
||||
|
||||
err = -ENOMEM;
|
||||
inst = kzalloc(sizeof(*inst) + sizeof(*ctx), GFP_KERNEL);
|
||||
@@ -787,15 +785,13 @@ out_put_ghash:
|
||||
|
||||
static struct crypto_instance *crypto_gcm_alloc(struct rtattr **tb)
|
||||
{
|
||||
int err;
|
||||
const char *cipher_name;
|
||||
char ctr_name[CRYPTO_MAX_ALG_NAME];
|
||||
char full_name[CRYPTO_MAX_ALG_NAME];
|
||||
|
||||
cipher_name = crypto_attr_alg_name(tb[1]);
|
||||
err = PTR_ERR(cipher_name);
|
||||
if (IS_ERR(cipher_name))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(cipher_name);
|
||||
|
||||
if (snprintf(ctr_name, CRYPTO_MAX_ALG_NAME, "ctr(%s)", cipher_name) >=
|
||||
CRYPTO_MAX_ALG_NAME)
|
||||
@@ -826,20 +822,17 @@ static struct crypto_template crypto_gcm_tmpl = {
|
||||
|
||||
static struct crypto_instance *crypto_gcm_base_alloc(struct rtattr **tb)
|
||||
{
|
||||
int err;
|
||||
const char *ctr_name;
|
||||
const char *ghash_name;
|
||||
char full_name[CRYPTO_MAX_ALG_NAME];
|
||||
|
||||
ctr_name = crypto_attr_alg_name(tb[1]);
|
||||
err = PTR_ERR(ctr_name);
|
||||
if (IS_ERR(ctr_name))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(ctr_name);
|
||||
|
||||
ghash_name = crypto_attr_alg_name(tb[2]);
|
||||
err = PTR_ERR(ghash_name);
|
||||
if (IS_ERR(ghash_name))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(ghash_name);
|
||||
|
||||
if (snprintf(full_name, CRYPTO_MAX_ALG_NAME, "gcm_base(%s,%s)",
|
||||
ctr_name, ghash_name) >= CRYPTO_MAX_ALG_NAME)
|
||||
@@ -971,17 +964,15 @@ static struct crypto_instance *crypto_rfc4106_alloc(struct rtattr **tb)
|
||||
int err;
|
||||
|
||||
algt = crypto_get_attr_type(tb);
|
||||
err = PTR_ERR(algt);
|
||||
if (IS_ERR(algt))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(algt);
|
||||
|
||||
if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
ccm_name = crypto_attr_alg_name(tb[1]);
|
||||
err = PTR_ERR(ccm_name);
|
||||
if (IS_ERR(ccm_name))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(ccm_name);
|
||||
|
||||
inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
|
||||
if (!inst)
|
||||
@@ -1222,17 +1213,15 @@ static struct crypto_instance *crypto_rfc4543_alloc(struct rtattr **tb)
|
||||
int err;
|
||||
|
||||
algt = crypto_get_attr_type(tb);
|
||||
err = PTR_ERR(algt);
|
||||
if (IS_ERR(algt))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(algt);
|
||||
|
||||
if ((algt->type ^ CRYPTO_ALG_TYPE_AEAD) & algt->mask)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
ccm_name = crypto_attr_alg_name(tb[1]);
|
||||
err = PTR_ERR(ccm_name);
|
||||
if (IS_ERR(ccm_name))
|
||||
return ERR_PTR(err);
|
||||
return ERR_CAST(ccm_name);
|
||||
|
||||
inst = kzalloc(sizeof(*inst) + sizeof(*spawn), GFP_KERNEL);
|
||||
if (!inst)
|
||||
|
Reference in New Issue
Block a user