From 2a1288ff89322a2f49c79f6d1832c8164c14a05c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 10 Jun 2015 19:10:47 +0200 Subject: 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. --- src/core/namespace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/core/namespace.c') 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; -- cgit v1.2.3-54-g00ecf