summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-09 20:47:34 +0200
committerTom Gundersen <teg@jklm.no>2015-10-11 15:04:16 +0200
commit957325b7637a4d3a16a3cea5e2c6b36faa0e1be7 (patch)
tree9bc931b069e40b28c2e753e2194e576f687826eb /src/network
parent5c416fc40818ee271c4ae89909e7780382aa39bb (diff)
networkd: link - refactor (un)ref
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-link.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index eebefda2e1..6c35cafbf5 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -336,15 +336,28 @@ static void link_free(Link *link) {
}
Link *link_unref(Link *link) {
- if (link && (-- link->n_ref <= 0))
- link_free(link);
+ if (!link)
+ return NULL;
+
+ assert(link->n_ref > 0);
+
+ link->n_ref --;
+
+ if (link->n_ref > 0)
+ return NULL;
+
+ link_free(link);
return NULL;
}
Link *link_ref(Link *link) {
- if (link)
- assert_se(++ link->n_ref >= 2);
+ if (!link)
+ return NULL;
+
+ assert(link->n_ref > 0);
+
+ link->n_ref ++;
return link;
}