autofs-5.1.6 - use master_list_empty() for list empty check From: Ian Kent For consistency use the master_list_empty() function for list empty checks everywhere. Signed-off-by: Ian Kent --- CHANGELOG | 1 + daemon/automount.c | 2 +- daemon/master.c | 24 +++++++++++++++++------- include/master.h | 1 + 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5db1d7df..58f13c33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -68,6 +68,7 @@ xx/xx/2020 autofs-5.1.7 - only add expre alarm for active mounts. - move submount check into conditional_alarm_add(). - move lib/master.c to daemon/master.c. +- use master_list_empty() for list empty check. 07/10/2019 autofs-5.1.6 - support strictexpire mount option. diff --git a/daemon/automount.c b/daemon/automount.c index 559378bf..5b8e04d8 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -1597,7 +1597,7 @@ static void *statemachine(void *arg) case SIGUSR2: master_mutex_lock(); if (list_empty(&master_list->completed)) { - if (list_empty(&master_list->mounts)) { + if (__master_list_empty(master_list)) { master_mutex_unlock(); return NULL; } diff --git a/daemon/master.c b/daemon/master.c index 5ce7aed6..da527a61 100644 --- a/daemon/master.c +++ b/daemon/master.c @@ -1110,7 +1110,7 @@ int master_read_master(struct master *master, time_t age) master_mount_mounts(master, age); } - if (list_empty(&master->mounts)) + if (__master_list_empty(master)) warn(logopt, "no mounts in table"); master_mutex_unlock(); @@ -1625,7 +1625,7 @@ int dump_map(struct master *master, const char *type, const char *name) { struct list_head *p, *head; - if (list_empty(&master->mounts)) { + if (__master_list_empty(master)) { printf("no master map entries found\n"); return 1; } @@ -1743,7 +1743,7 @@ int master_show_mounts(struct master *master) printf("global options %s be appended to map entries\n", append); } - if (list_empty(&master->mounts)) { + if (__master_list_empty(master)) { printf("no master map entries found\n\n"); return 1; } @@ -1831,13 +1831,22 @@ int master_show_mounts(struct master *master) return 1; } -int master_list_empty(struct master *master) +int __master_list_empty(struct master *master) { int res = 0; - master_mutex_lock(); if (list_empty(&master->mounts)) res = 1; + + return res; +} + +int master_list_empty(struct master *master) +{ + int res; + + master_mutex_lock(); + res = __master_list_empty(master); master_mutex_unlock(); return res; @@ -1859,7 +1868,8 @@ int master_done(struct master *master) master_free_mapent_sources(entry, 1); master_free_mapent(entry); } - if (list_empty(&master->mounts)) + + if (__master_list_empty(master)) res = 1; return res; @@ -1872,7 +1882,7 @@ unsigned int master_get_logopt(void) int master_kill(struct master *master) { - if (!list_empty(&master->mounts)) + if (!master_list_empty(master)) return 0; if (master->name) diff --git a/include/master.h b/include/master.h index 8faae754..0806b372 100644 --- a/include/master.h +++ b/include/master.h @@ -123,6 +123,7 @@ int master_mount_mounts(struct master *, time_t); int dump_map(struct master *, const char *, const char *); int master_show_mounts(struct master *); unsigned int master_get_logopt(void); +int __master_list_empty(struct master *); int master_list_empty(struct master *); int master_done(struct master *); int master_kill(struct master *);