macro: introduce new TAKE_FD() macro

This is similar to TAKE_PTR() but operates on file descriptors, and thus
assigns -1 to the fd parameter after returning it.

Removes 60 lines from our codebase. Pretty good too I think.
This commit is contained in:
Lennart Poettering
2018-03-22 20:30:40 +01:00
parent 2f4cefe6ce
commit c10d6bdb89
25 changed files with 64 additions and 130 deletions
+1 -4
View File
@@ -168,8 +168,5 @@ int memfd_new_and_map(const char *name, size_t sz, void **p) {
if (r < 0)
return r;
r = fd;
fd = -1;
return r;
return TAKE_FD(fd);
}