From: Karel Zak Date: Tue, 16 Dec 2014 08:16:09 +0000 (+0100) Subject: libmount: monitor unref function refactoring X-Git-Tag: v2.26-rc1~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36813a2128948f7f24128213733e03e7172b93f2;p=thirdparty%2Futil-linux.git libmount: monitor unref function refactoring Signed-off-by: Karel Zak --- diff --git a/libmount/src/monitor.c b/libmount/src/monitor.c index 739bd1afce..6d6b2056a3 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); + } } }