summaryrefslogtreecommitdiffstats
path: root/libmount/src/monitor.c
diff options
context:
space:
mode:
authorKarel Zak2014-12-16 09:16:09 +0100
committerKarel Zak2015-01-06 16:19:02 +0100
commit36813a2128948f7f24128213733e03e7172b93f2 (patch)
tree9b92b4d7a2415114762672282dcfd3364b58620c /libmount/src/monitor.c
parentlibmount: cleanup monitor test (diff)
downloadkernel-qcow2-util-linux-36813a2128948f7f24128213733e03e7172b93f2.tar.gz
kernel-qcow2-util-linux-36813a2128948f7f24128213733e03e7172b93f2.tar.xz
kernel-qcow2-util-linux-36813a2128948f7f24128213733e03e7172b93f2.zip
libmount: monitor unref function refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/monitor.c')
-rw-r--r--libmount/src/monitor.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c
index 739bd1afc..6d6b2056a 100644
--- a/libmount/src/monitor.c
+++ b/libmount/src/monitor.c
@@ -87,16 +87,6 @@ static void free_monitor_entry(struct monitor_entry *me)
free(me);
}
-static void free_monitor(struct libmnt_monitor *mn)
-{
-
- while (!list_empty(&mn->ents)) {
- struct monitor_entry *me = list_entry(mn->ents.next,
- struct monitor_entry, ents);
- free_monitor_entry(me);
- }
-}
-
/**
* mnt_unref_monitor:
* @mn: monitor pointer
@@ -106,10 +96,16 @@ static void free_monitor(struct libmnt_monitor *mn)
*/
void mnt_unref_monitor(struct libmnt_monitor *mn)
{
- if (mn) {
- mn->refcount--;
- if (mn->refcount <= 0)
- free_monitor(mn);
+ if (!mn)
+ return;
+
+ mn->refcount--;
+ if (mn->refcount <= 0) {
+ while (!list_empty(&mn->ents)) {
+ struct monitor_entry *me = list_entry(mn->ents.next,
+ struct monitor_entry, ents);
+ free_monitor_entry(me);
+ }
}
}