Blame SOURCES/autofs-5.1.7-add-ext_mount_hash_mutex-lock-helpers.patch

49b67f
autofs-5.1.7 - add ext_mount_hash_mutex lock helpers
49b67f
49b67f
From: Ian Kent <raven@themaw.net>
49b67f
49b67f
Coverity: check_return: Calling "pthread_mutex_lock" without checking
49b67f
	  return value.
49b67f
49b67f
Well, I use helpers to do this in many places so can't really disagree.
49b67f
49b67f
Signed-off-by: Ian Kent <raven@themaw.net>
49b67f
---
49b67f
 CHANGELOG    |    1 +
49b67f
 lib/mounts.c |   26 ++++++++++++++++++++------
49b67f
 2 files changed, 21 insertions(+), 6 deletions(-)
49b67f
49b67f
--- autofs-5.1.4.orig/CHANGELOG
49b67f
+++ autofs-5.1.4/CHANGELOG
49b67f
@@ -65,6 +65,7 @@
49b67f
 - fix double free in parse_mapent().
49b67f
 - refactor lookup_prune_one_cache() a bit.
49b67f
 - cater for empty mounts list in mnts_get_expire_list().
49b67f
+- add ext_mount_hash_mutex lock helpers.
49b67f
 
49b67f
 xx/xx/2018 autofs-5.1.5
49b67f
 - fix flag file permission.
49b67f
--- autofs-5.1.4.orig/lib/mounts.c
49b67f
+++ autofs-5.1.4/lib/mounts.c
49b67f
@@ -788,6 +788,20 @@ char *make_mnt_name_string(char *path)
49b67f
 	return mnt_name;
49b67f
 }
49b67f
 
49b67f
+static void ext_mount_hash_mutex_lock(void)
49b67f
+{
49b67f
+	int status = pthread_mutex_lock(&ext_mount_hash_mutex);
49b67f
+	if (status)
49b67f
+		fatal(status);
49b67f
+}
49b67f
+
49b67f
+static void ext_mount_hash_mutex_unlock(void)
49b67f
+{
49b67f
+	int status = pthread_mutex_unlock(&ext_mount_hash_mutex);
49b67f
+	if (status)
49b67f
+		fatal(status);
49b67f
+}
49b67f
+
49b67f
 static struct ext_mount *ext_mount_lookup(const char *mp)
49b67f
 {
49b67f
 	uint32_t hval = hash(mp, HASH_SIZE(ext_mounts_hash));
49b67f
@@ -806,7 +820,7 @@ int ext_mount_add(const char *path, cons
49b67f
 	struct ext_mount *em;
49b67f
 	int ret = 0;
49b67f
 
49b67f
-	pthread_mutex_lock(&ext_mount_hash_mutex);
49b67f
+	ext_mount_hash_mutex_lock();
49b67f
 
49b67f
 	em = ext_mount_lookup(path);
49b67f
 	if (em) {
49b67f
@@ -840,7 +854,7 @@ int ext_mount_add(const char *path, cons
49b67f
 
49b67f
 	ret = 1;
49b67f
 done:
49b67f
-	pthread_mutex_unlock(&ext_mount_hash_mutex);
49b67f
+	ext_mount_hash_mutex_unlock();
49b67f
 	return ret;
49b67f
 }
49b67f
 
49b67f
@@ -849,7 +863,7 @@ int ext_mount_remove(const char *path)
49b67f
 	struct ext_mount *em;
49b67f
 	int ret = 0;
49b67f
 
49b67f
-	pthread_mutex_lock(&ext_mount_hash_mutex);
49b67f
+	ext_mount_hash_mutex_lock();
49b67f
 
49b67f
 	em = ext_mount_lookup(path);
49b67f
 	if (!em)
49b67f
@@ -867,7 +881,7 @@ int ext_mount_remove(const char *path)
49b67f
 		ret = 1;
49b67f
 	}
49b67f
 done:
49b67f
-	pthread_mutex_unlock(&ext_mount_hash_mutex);
49b67f
+	ext_mount_hash_mutex_unlock();
49b67f
 	return ret;
49b67f
 }
49b67f
 
49b67f
@@ -876,13 +890,13 @@ int ext_mount_inuse(const char *path)
49b67f
 	struct ext_mount *em;
49b67f
 	int ret = 0;
49b67f
 
49b67f
-	pthread_mutex_lock(&ext_mount_hash_mutex);
49b67f
+	ext_mount_hash_mutex_lock();
49b67f
 	em = ext_mount_lookup(path);
49b67f
 	if (!em)
49b67f
 		goto done;
49b67f
 	ret = em->ref;
49b67f
 done:
49b67f
-	pthread_mutex_unlock(&ext_mount_hash_mutex);
49b67f
+	ext_mount_hash_mutex_unlock();
49b67f
 	return ret;
49b67f
 }
49b67f