summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-19 15:21:45 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-10-19 15:49:58 +0200
commit956b3e8bd580da03473fb6930cede23f4e188640 (patch)
tree6fd6b8eac0d6a2a9ef74440d9ca7d65cf87ada21
parentd29115c138dcd88172eb2668cf0a40b5bc428716 (diff)
downloadNetworkManager-956b3e8bd580da03473fb6930cede23f4e188640.tar.gz
shared: add nm_steal_fd() helper function
-rw-r--r--shared/nm-utils/nm-macros-internal.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h
index a8f78e6d2d..5376e615ec 100644
--- a/shared/nm-utils/nm-macros-internal.h
+++ b/shared/nm-utils/nm-macros-internal.h
@@ -1151,6 +1151,19 @@ nm_decode_version (guint version, guint *major, guint *minor, guint *micro)
/*****************************************************************************/
+static inline int
+nm_steal_fd (int *p_fd)
+{
+ int fd;
+
+ if ( p_fd
+ && ((fd = *p_fd) > 0)) {
+ *p_fd = -1;
+ return fd;
+ }
+ return -1;
+}
+
/**
* nm_close:
*