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

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