diff options
author | Darren Tucker <dtucker@zip.com.au> | 2008-11-23 14:03:19 +1100 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2008-11-23 14:03:19 +1100 |
commit | 69087eae6d44c2266b1bea1a3b3de5a7b7e551e1 (patch) | |
tree | a1038094d7554b643018f85746876bcb7ea2f1f9 /monitor_fdpass.c | |
parent | 0f4d2c02f275ad9f80ccd7435ffb407a8be61e9a (diff) |
- (dtucker) [monitor_fdpass.c] Reduce diff vs OpenBSD by moving some
declarations, removing an unnecessary union member and adding whitespace.
ok djm some time ago.
Diffstat (limited to 'monitor_fdpass.c')
-rw-r--r-- | monitor_fdpass.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/monitor_fdpass.c b/monitor_fdpass.c index cab538bc9..f68c3728a 100644 --- a/monitor_fdpass.c +++ b/monitor_fdpass.c | |||
@@ -45,17 +45,16 @@ mm_send_fd(int sock, int fd) | |||
45 | { | 45 | { |
46 | #if defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) | 46 | #if defined(HAVE_SENDMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) |
47 | struct msghdr msg; | 47 | struct msghdr msg; |
48 | struct iovec vec; | ||
49 | char ch = '\0'; | ||
50 | ssize_t n; | ||
51 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR | 48 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR |
52 | union { | 49 | union { |
53 | struct cmsghdr hdr; | 50 | struct cmsghdr hdr; |
54 | char tmp[CMSG_SPACE(sizeof(int))]; | ||
55 | char buf[CMSG_SPACE(sizeof(int))]; | 51 | char buf[CMSG_SPACE(sizeof(int))]; |
56 | } cmsgbuf; | 52 | } cmsgbuf; |
57 | struct cmsghdr *cmsg; | 53 | struct cmsghdr *cmsg; |
58 | #endif | 54 | #endif |
55 | struct iovec vec; | ||
56 | char ch = '\0'; | ||
57 | ssize_t n; | ||
59 | 58 | ||
60 | memset(&msg, 0, sizeof(msg)); | 59 | memset(&msg, 0, sizeof(msg)); |
61 | #ifdef HAVE_ACCRIGHTS_IN_MSGHDR | 60 | #ifdef HAVE_ACCRIGHTS_IN_MSGHDR |
@@ -99,10 +98,6 @@ mm_receive_fd(int sock) | |||
99 | { | 98 | { |
100 | #if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) | 99 | #if defined(HAVE_RECVMSG) && (defined(HAVE_ACCRIGHTS_IN_MSGHDR) || defined(HAVE_CONTROL_IN_MSGHDR)) |
101 | struct msghdr msg; | 100 | struct msghdr msg; |
102 | struct iovec vec; | ||
103 | ssize_t n; | ||
104 | char ch; | ||
105 | int fd; | ||
106 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR | 101 | #ifndef HAVE_ACCRIGHTS_IN_MSGHDR |
107 | union { | 102 | union { |
108 | struct cmsghdr hdr; | 103 | struct cmsghdr hdr; |
@@ -110,6 +105,10 @@ mm_receive_fd(int sock) | |||
110 | } cmsgbuf; | 105 | } cmsgbuf; |
111 | struct cmsghdr *cmsg; | 106 | struct cmsghdr *cmsg; |
112 | #endif | 107 | #endif |
108 | struct iovec vec; | ||
109 | ssize_t n; | ||
110 | char ch; | ||
111 | int fd; | ||
113 | 112 | ||
114 | memset(&msg, 0, sizeof(msg)); | 113 | memset(&msg, 0, sizeof(msg)); |
115 | vec.iov_base = &ch; | 114 | vec.iov_base = &ch; |
@@ -128,6 +127,7 @@ mm_receive_fd(int sock) | |||
128 | error("%s: recvmsg: %s", __func__, strerror(errno)); | 127 | error("%s: recvmsg: %s", __func__, strerror(errno)); |
129 | return -1; | 128 | return -1; |
130 | } | 129 | } |
130 | |||
131 | if (n != 1) { | 131 | if (n != 1) { |
132 | error("%s: recvmsg: expected received 1 got %ld", | 132 | error("%s: recvmsg: expected received 1 got %ld", |
133 | __func__, (long)n); | 133 | __func__, (long)n); |
@@ -145,6 +145,7 @@ mm_receive_fd(int sock) | |||
145 | error("%s: no message header", __func__); | 145 | error("%s: no message header", __func__); |
146 | return -1; | 146 | return -1; |
147 | } | 147 | } |
148 | |||
148 | #ifndef BROKEN_CMSG_TYPE | 149 | #ifndef BROKEN_CMSG_TYPE |
149 | if (cmsg->cmsg_type != SCM_RIGHTS) { | 150 | if (cmsg->cmsg_type != SCM_RIGHTS) { |
150 | error("%s: expected type %d got %d", __func__, | 151 | error("%s: expected type %d got %d", __func__, |