Skip to content

Commit 8db0507

Browse files
Julia Lawallherbertx
authored andcommitted
crypto: Use ERR_CAST
Use ERR_CAST(x) rather than ERR_PTR(PTR_ERR(x)). The former makes more clear what is the purpose of the operation, which otherwise looks like a no-op. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ type T; T x; identifier f; @@ T f (...) { <+... - ERR_PTR(PTR_ERR(x)) + x ...+> } @@ expression x; @@ - ERR_PTR(PTR_ERR(x)) + ERR_CAST(x) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 1efbd15 commit 8db0507

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎crypto/authenc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ static struct crypto_instance *crypto_authenc_alloc(struct rtattr **tb)
616616
auth = ahash_attr_alg(tb[1], CRYPTO_ALG_TYPE_HASH,
617617
CRYPTO_ALG_TYPE_AHASH_MASK);
618618
if (IS_ERR(auth))
619-
return ERR_PTR(PTR_ERR(auth));
619+
return ERR_CAST(auth);
620620

621621
auth_base = &auth->base;
622622

‎crypto/ctr.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ static struct crypto_instance *crypto_ctr_alloc(struct rtattr **tb)
185185
alg = crypto_attr_alg(tb[1], CRYPTO_ALG_TYPE_CIPHER,
186186
CRYPTO_ALG_TYPE_MASK);
187187
if (IS_ERR(alg))
188-
return ERR_PTR(PTR_ERR(alg));
188+
return ERR_CAST(alg);
189189

190190
/* Block size must be >= 4 bytes. */
191191
err = -EINVAL;

‎crypto/xts.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static struct crypto_instance *alloc(struct rtattr **tb)
224224
alg = crypto_get_attr_alg(tb, CRYPTO_ALG_TYPE_CIPHER,
225225
CRYPTO_ALG_TYPE_MASK);
226226
if (IS_ERR(alg))
227-
return ERR_PTR(PTR_ERR(alg));
227+
return ERR_CAST(alg);
228228

229229
inst = crypto_alloc_instance("xts", alg);
230230
if (IS_ERR(inst))

0 commit comments

Comments
 (0)