projects
/
platform
/
upstream
/
systemd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5c416fc
)
networkd: link - refactor (un)ref
author
Tom Gundersen
<teg@jklm.no>
Fri, 9 Oct 2015 18:47:34 +0000
(20:47 +0200)
committer
Tom Gundersen
<teg@jklm.no>
Sun, 11 Oct 2015 13:04:16 +0000
(15:04 +0200)
src/network/networkd-link.c
patch
|
blob
|
history
diff --git
a/src/network/networkd-link.c
b/src/network/networkd-link.c
index
eebefda
..
6c35caf
100644
(file)
--- 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;
}