git » libfiu » commit 3cc2f54

Simplify initialization code

author Alberto Bertogli
2009-03-27 15:19:16 UTC
committer Alberto Bertogli
2009-03-27 15:19:16 UTC
parent 734b19cf153fa3f981aa602f27c2bac815cbf084

Simplify initialization code

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

libfiu/fiu.c +11 -9

diff --git a/libfiu/fiu.c b/libfiu/fiu.c
index b6e8161..d638378 100644
--- a/libfiu/fiu.c
+++ b/libfiu/fiu.c
@@ -159,17 +159,19 @@ static int shrink_enabled_fails(void)
 int fiu_init(unsigned int flags)
 {
 	ef_wlock();
-	if (!initialized) {
-		/* first time we get called */
-		pthread_key_create(&last_failinfo_key, NULL);
+	if (initialized) {
+		ef_wunlock();
+		return 0;
+	}
 
-		enabled_fails = NULL;
-		enabled_fails_last = NULL;
-		enabled_fails_len = 0;
-		enabled_fails_nfree = 0;
+	pthread_key_create(&last_failinfo_key, NULL);
 
-		initialized = 1;
-	}
+	enabled_fails = NULL;
+	enabled_fails_last = NULL;
+	enabled_fails_len = 0;
+	enabled_fails_nfree = 0;
+
+	initialized = 1;
 
 	ef_wunlock();
 	return 0;