diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-06-10 19:10:47 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-06-10 19:29:47 +0200 |
commit | 2a1288ff89322a2f49c79f6d1832c8164c14a05c (patch) | |
tree | 02cc41ade7b814d258b183c0ac88670163194913 /src/core | |
parent | 5410b2ed62289d8ab6575e64951ac7b6bda51d40 (diff) |
util: introduce CMSG_FOREACH() macro and make use of it everywhere
It's only marginally shorter then the usual for() loop, but certainly
more readable.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/manager.c | 2 | ||||
-rw-r--r-- | src/core/namespace.c | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 564fb5d579..eb80dd1b46 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1546,7 +1546,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t return -errno; } - for (cmsg = CMSG_FIRSTHDR(&msghdr); cmsg; cmsg = CMSG_NXTHDR(&msghdr, cmsg)) { + CMSG_FOREACH(cmsg, &msghdr) { if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { fd_array = (int*) CMSG_DATA(cmsg); diff --git a/src/core/namespace.c b/src/core/namespace.c index 01a817bf23..045321e1d4 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -696,12 +696,11 @@ int setup_netns(int netns_storage_socket[2]) { } else { /* Yay, found something, so let's join the namespace */ - for (cmsg = CMSG_FIRSTHDR(&mh); cmsg; cmsg = CMSG_NXTHDR(&mh, cmsg)) { + CMSG_FOREACH(cmsg, &mh) if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { assert(cmsg->cmsg_len == CMSG_LEN(sizeof(int))); netns = *(int*) CMSG_DATA(cmsg); } - } if (setns(netns, CLONE_NEWNET) < 0) { r = -errno; |