From 3cc2f54e12ad1b45e7fd98d5b631c66a60c84566 Mon Sep 17 00:00:00 2001
From: Alberto Bertogli <albertito@blitiri.com.ar>
Date: Fri, 27 Mar 2009 12:19:16 -0300
Subject: [PATCH 06/48] Simplify initialization code

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
---
 libfiu/fiu.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

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;
-- 
1.6.2.2.646.gb214

