]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/fdset.c
test-execute: Add tests for new PassEnvironment= directive
[thirdparty/systemd.git] / src / basic / fdset.c
index 6101b628ec2fd245656c50e01324f6ee6cf7c0af..42b0b2b98f635eaa33c8a5b2c7c24e537264d2b0 100644 (file)
 #include <dirent.h>
 #include <fcntl.h>
 
+#include "sd-daemon.h"
+
+#include "dirent-util.h"
+#include "fd-util.h"
+#include "fdset.h"
+#include "macro.h"
+#include "parse-util.h"
 #include "set.h"
 #include "util.h"
-#include "macro.h"
-#include "fdset.h"
-#include "sd-daemon.h"
 
 #define MAKE_SET(s) ((Set*) s)
 #define MAKE_FDSET(s) ((FDSet*) s)
@@ -40,7 +44,7 @@ FDSet *fdset_new(void) {
         return MAKE_FDSET(set_new(NULL));
 }
 
-int fdset_new_array(FDSet **ret, int *fds, unsigned n_fds) {
+int fdset_new_array(FDSet **ret, const int *fds, unsigned n_fds) {
         unsigned i;
         FDSet *s;
         int r;
@@ -201,9 +205,11 @@ int fdset_cloexec(FDSet *fds, bool b) {
 
         assert(fds);
 
-        SET_FOREACH(p, MAKE_SET(fds), i)
-                if ((r = fd_cloexec(PTR_TO_FD(p), b)) < 0)
+        SET_FOREACH(p, MAKE_SET(fds), i) {
+                r = fd_cloexec(PTR_TO_FD(p), b);
+                if (r < 0)
                         return r;
+        }
 
         return 0;
 }
@@ -267,8 +273,7 @@ bool fdset_isempty(FDSet *fds) {
 int fdset_iterate(FDSet *s, Iterator *i) {
         void *p;
 
-        p = set_iterate(MAKE_SET(s), i);
-        if (!p)
+        if (!set_iterate(MAKE_SET(s), i, &p))
                 return -ENOENT;
 
         return PTR_TO_FD(p);