ALSA: sound/soc/at32: Useless NULL test

Author: Julien Brunel <brunel@diku.dk>

The test (ssc != NULL) can only be reached if the call to the function
ssc_request, the result of which ssc is assigned, succeeds. Moreover,
two statements assign NULL to ssc just before a return, which is useless
since it is a local variable. So, we suggest to delete the test and
the two assignments.

A simplified version of the semantic match that finds this problem is
as follows:
(http://www.emn.fr/x-info/coccinelle/)

// 
@bad_null_test@
expression x,E;
@@
x = ssc_request(...)
... when != x = E
* x != NULL
// 

Signed-off-by: Julien Brunel 
Signed-off-by: Julia Lawall 
Acked-by: Mark Brown 
Signed-off-by: Takashi Iwai 
Signed-off-by: Jaroslav Kysela 
---
 sound/soc/at32/playpaq_wm8510.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
 
diff --git a/sound/soc/at32/playpaq_wm8510.c b/sound/soc/at32/playpaq_wm8510.c
index 7e6560b..98a2d58 100644
--- a/sound/soc/at32/playpaq_wm8510.c
+++ b/sound/soc/at32/playpaq_wm8510.c
@@ -406,7 +406,6 @@ static int __init playpaq_asoc_init(void)
 	ssc = ssc_request(0);
 	if (IS_ERR(ssc)) {
 		ret = PTR_ERR(ssc);
-		ssc = NULL;
 		goto err_ssc;
 	}
 	ssc_p->ssc = ssc;
@@ -477,10 +476,7 @@ err_pll0:
 		_gclk0 = NULL;
 	}
 err_gclk0:
-	if (ssc != NULL) {
-		ssc_free(ssc);
-		ssc = NULL;
-	}
+	ssc_free(ssc);
 err_ssc:
 	return ret;
 }
BtrLinux
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.