]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: monitor unref function refactoring
authorKarel Zak <kzak@redhat.com>
Tue, 16 Dec 2014 08:16:09 +0000 (09:16 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 6 Jan 2015 15:19:02 +0000 (16:19 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/monitor.c

index 739bd1afce5709afc120727c05d5376c94be3f88..6d6b2056a34713c3a6fd5419b0cb96ae020870f6 100644 (file)
@@ -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);
+               }
        }
 }