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

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