Blame SOURCES/autofs-5.1.0-add-mutex-call-return-check-in-defaults_c.patch

306fa1
autofs-5.1.0 - add mutex call return check in defaults.c
306fa1
306fa1
From: Ian Kent <ikent@redhat.com>
306fa1
306fa1
Even though pthread_mutex_lock() and pthread_mutex_unlock() should
306fa1
never fail checking their return has very occassionally been useful
306fa1
and isn't consistent with the usage elsewhere.
306fa1
---
306fa1
 CHANGELOG      |    1 +
306fa1
 lib/defaults.c |   55 ++++++++++++++++++++++++++++++++++---------------------
306fa1
 2 files changed, 35 insertions(+), 21 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -145,6 +145,7 @@
306fa1
 - fix some out of order evaluations in parse_amd.c.
306fa1
 - fix copy and paste error in dup_defaults_entry().
306fa1
 - fix leak in parse_mount().
306fa1
+- add mutex call return check in defaults.c.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/lib/defaults.c
306fa1
+++ autofs-5.0.7/lib/defaults.c
306fa1
@@ -171,6 +171,19 @@ static int conf_update(const char *, con
306fa1
 static void conf_delete(const char *, const char *);
306fa1
 static struct conf_option *conf_lookup(const char *, const char *);
306fa1
 
306fa1
+static void defaults_mutex_lock(void)
306fa1
+{
306fa1
+	int status = pthread_mutex_lock(&conf_mutex);
306fa1
+	if (status)
306fa1
+		fatal(status);
306fa1
+}
306fa1
+
306fa1
+static void defaults_mutex_unlock(void)
306fa1
+{
306fa1
+	int status = pthread_mutex_unlock(&conf_mutex);
306fa1
+	if (status)
306fa1
+		fatal(status);
306fa1
+}
306fa1
 
306fa1
 static void message(unsigned int to_syslog, const char *msg, ...)
306fa1
 {
306fa1
@@ -253,9 +266,9 @@ static void __conf_release(void)
306fa1
 
306fa1
 void defaults_conf_release(void)
306fa1
 {
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	__conf_release();
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 	return;
306fa1
 }
306fa1
 
306fa1
@@ -727,11 +740,11 @@ static unsigned int conf_section_exists(
306fa1
 		return 0;
306fa1
 
306fa1
 	ret = 0;
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(section, section);
306fa1
 	if (co)
306fa1
 		ret = 1;
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 
306fa1
 	return ret;
306fa1
 }
306fa1
@@ -1057,7 +1070,7 @@ unsigned int defaults_read_config(unsign
306fa1
 
306fa1
 	conf = oldconf = NULL;
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	if (!config) {
306fa1
 		if (conf_init()) {
306fa1
 			message(to_syslog, "failed to init config");
306fa1
@@ -1149,7 +1162,7 @@ out:
306fa1
 		fclose(conf);
306fa1
 	if (oldconf)
306fa1
 		fclose(oldconf);
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 	return ret;
306fa1
 }
306fa1
 
306fa1
@@ -1158,11 +1171,11 @@ static char *conf_get_string(const char
306fa1
 	struct conf_option *co;
306fa1
 	char *val = NULL;
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(section, name);
306fa1
 	if (co && co->value)
306fa1
 		val = strdup(co->value);
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 	return val;
306fa1
 }
306fa1
 
306fa1
@@ -1171,11 +1184,11 @@ static long conf_get_number(const char *
306fa1
 	struct conf_option *co;
306fa1
 	long val = -1;
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(section, name);
306fa1
 	if (co && co->value)
306fa1
 		val = atol(co->value);
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 	return val;
306fa1
 }
306fa1
 
306fa1
@@ -1184,7 +1197,7 @@ static int conf_get_yesno(const char *se
306fa1
 	struct conf_option *co;
306fa1
 	int val = -1;
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(section, name);
306fa1
 	if (co && co->value) {
306fa1
 		if (isdigit(*co->value))
306fa1
@@ -1194,7 +1207,7 @@ static int conf_get_yesno(const char *se
306fa1
 		else if (!strcasecmp(co->value, "no"))
306fa1
 			val = 0;
306fa1
 	}
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 	return val;
306fa1
 }
306fa1
 
306fa1
@@ -1271,10 +1284,10 @@ struct list_head *defaults_get_uris(void
306fa1
 		return NULL;
306fa1
 	}
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(autofs_gbl_sec, NAME_LDAP_URI);
306fa1
 	if (!co) {
306fa1
-		pthread_mutex_unlock(&conf_mutex);
306fa1
+		defaults_mutex_unlock();
306fa1
 		free(list);
306fa1
 		return NULL;
306fa1
 	}
306fa1
@@ -1285,7 +1298,7 @@ struct list_head *defaults_get_uris(void
306fa1
 				add_uris(co->value, list);
306fa1
 		co = co->next;
306fa1
 	}
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 
306fa1
 	if (list_empty(list)) {
306fa1
 		free(list);
306fa1
@@ -1397,10 +1410,10 @@ struct ldap_searchdn *defaults_get_searc
306fa1
 	if (!defaults_read_config(0))
306fa1
 		return NULL;
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(autofs_gbl_sec, NAME_SEARCH_BASE);
306fa1
 	if (!co) {
306fa1
-		pthread_mutex_unlock(&conf_mutex);
306fa1
+		defaults_mutex_unlock();
306fa1
 		return NULL;
306fa1
 	}
306fa1
 
306fa1
@@ -1416,7 +1429,7 @@ struct ldap_searchdn *defaults_get_searc
306fa1
 
306fa1
 		new = alloc_searchdn(co->value);
306fa1
 		if (!new) {
306fa1
-			pthread_mutex_unlock(&conf_mutex);
306fa1
+			defaults_mutex_unlock();
306fa1
 			defaults_free_searchdns(sdn);
306fa1
 			return NULL;
306fa1
 		}
306fa1
@@ -1433,7 +1446,7 @@ struct ldap_searchdn *defaults_get_searc
306fa1
 
306fa1
 		co = co->next;
306fa1
 	}
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 
306fa1
 	return sdn;
306fa1
 }
306fa1
@@ -1511,9 +1524,9 @@ int defaults_master_set(void)
306fa1
 {
306fa1
 	struct conf_option *co;
306fa1
 
306fa1
-	pthread_mutex_lock(&conf_mutex);
306fa1
+	defaults_mutex_lock();
306fa1
 	co = conf_lookup(autofs_gbl_sec, NAME_MASTER_MAP);
306fa1
-	pthread_mutex_unlock(&conf_mutex);
306fa1
+	defaults_mutex_unlock();
306fa1
 	if (co)
306fa1
 		return 1;
306fa1
 	return 0;