diff mbox

fix ptr_ret.cocci warnings

Message ID alpine.DEB.2.20.1705151850590.4315@hadrien (mailing list archive)
State Not Applicable
Delegated to: Herbert Xu
Headers show

Commit Message

Julia Lawall May 15, 2017, 10:52 a.m. UTC
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

CC: Stephan Müller <smueller@chronox.de>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---

Not very important, but the code can be a little simpler.

 lrng_base.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Comments

Stephan Mueller May 15, 2017, 10:56 a.m. UTC | #1
Am Montag, 15. Mai 2017, 12:52:11 CEST schrieb Julia Lawall:

Hi Julia,

> Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
> 
> Generated by: scripts/coccinelle/api/ptr_ret.cocci

Thank you, included -- it will be present in the next release.

Ciao
Stephan
diff mbox

Patch

--- a/drivers/char/lrng_base.c
+++ b/drivers/char/lrng_base.c
@@ -1523,10 +1523,7 @@  static int lrng_alloc(void)
 	lrng_init_rng(key, sizeof(key));
 	lrng_pool.lrng_hash = lrng_hash_alloc(LRNG_HASH_NAME, key, sizeof(key));
 	memzero_explicit(key, sizeof(key));
-	if (IS_ERR(lrng_pool.lrng_hash))
-		return PTR_ERR(lrng_pool.lrng_hash);
-
-	return 0;
+	return PTR_ERR_OR_ZERO(lrng_pool.lrng_hash);
 }

 /************************** LRNG kernel interfaces ***************************/