summaryrefslogtreecommitdiffstats
path: root/audio/unix.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2007-09-05 14:27:18 +0000
committerJohan Hedberg <johan.hedberg@nokia.com>2007-09-05 14:27:18 +0000
commitc4e21c814832ea94f64821a2360a28074d03be1a (patch)
tree5e0292327179920ca4b7dbc39d4539168a1f3b56 /audio/unix.c
parent5e4e6d23323b869b36fb02d815dd4b928f94eacb (diff)
Cleanup fd passing a little
Diffstat (limited to 'audio/unix.c')
-rw-r--r--audio/unix.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/audio/unix.c b/audio/unix.c
index accf6efb..cf225ae5 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -122,24 +122,18 @@ static void client_free(struct unix_client *client)
and the sendmsg() system call with the cmsg_type field of a "struct cmsghdr" set
to SCM_RIGHTS and the data being an integer value equal to the handle of the
file descriptor to be passed.*/
-static int unix_sendmsg_fd(int sock, int fd, struct ipc_packet *pkt)
+static int unix_sendmsg_fd(int sock, int fd)
{
- char cmsg_b[CMSG_SPACE(sizeof(int))];
+ char cmsg_b[CMSG_SPACE(sizeof(int))], m = 'm';
struct cmsghdr *cmsg;
- struct iovec iov = {
- .iov_base = pkt,
- .iov_len = sizeof(struct ipc_packet)
- };
+ struct iovec iov = { &m, sizeof(m) };
+ struct msghdr msgh;
- struct msghdr msgh = {
- .msg_name = 0,
- .msg_namelen = 0,
- .msg_iov = &iov,
- .msg_iovlen = 1,
- .msg_control = &cmsg_b,
- .msg_controllen = CMSG_LEN(sizeof(int)),
- .msg_flags = 0
- };
+ memset(&msgh, 0, sizeof(msgh));
+ msgh.msg_iov = &iov;
+ msgh.msg_iovlen = 1;
+ msgh.msg_control = &cmsg_b;
+ msgh.msg_controllen = CMSG_LEN(sizeof(int));
cmsg = CMSG_FIRSTHDR(&msgh);
cmsg->cmsg_level = SOL_SOCKET;
@@ -237,7 +231,7 @@ static int unix_send_cfg(int sock, struct ipc_data_cfg *cfg, int fd)
debug("%d bytes sent", len);
if (fd != -1) {
- len = unix_sendmsg_fd(sock, fd, pkt);
+ len = unix_sendmsg_fd(sock, fd);
if (len < 0)
error("Error %s(%d)", strerror(errno), errno);
debug("%d bytes sent", len);