diff options
author | Michael Adam <obnox@samba.org> | 2014-09-29 11:54:12 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2014-09-30 16:36:09 +0200 |
commit | 2564a5fa578058953c9c2890566b4fdd51a744be (patch) | |
tree | b890751663a52f353ce2296159af3edc8b494c01 | |
parent | 9ddb66128134f9d8386a6db776dc226c6a3b14ac (diff) | |
download | samba-2564a5fa578058953c9c2890566b4fdd51a744be.tar.gz |
s3:unix_msg: use a buffer pointer instead of array indexes for the iov buffer
This is more obvious to read and a preparation for following commits.
Pair-Programmed-With: Volker Lendecke <vl@samba.org>
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
-rw-r--r-- | source3/lib/unix_msg/unix_msg.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source3/lib/unix_msg/unix_msg.c b/source3/lib/unix_msg/unix_msg.c index e6e7e020ee2..e38bec160f9 100644 --- a/source3/lib/unix_msg/unix_msg.c +++ b/source3/lib/unix_msg/unix_msg.c @@ -450,6 +450,7 @@ static int queue_msg(struct unix_dgram_send_queue *q, { struct unix_dgram_msg *msg; ssize_t buflen; + uint8_t *data_buf; size_t msglen; size_t fds_size = sizeof(int) * num_fds; int fds_copy[MIN(num_fds, INT8_MAX)]; @@ -516,15 +517,17 @@ static int queue_msg(struct unix_dgram_send_queue *q, msg->buflen = buflen; msg->sock = q->sock; - buflen = 0; + data_buf = msg->buf; for (i=0; i<iovlen; i++) { - memcpy(&msg->buf[buflen], iov[i].iov_base, iov[i].iov_len); - buflen += iov[i].iov_len; + memcpy(data_buf, iov[i].iov_base, iov[i].iov_len); + data_buf += iov[i].iov_len; } msg->num_fds = num_fds; if (msg->num_fds > 0) { - void *fds_ptr = (void *)&msg->buf[buflen+fds_padding]; + void *fds_ptr; + data_buf += fds_padding; + fds_ptr= (void *)data_buf; memcpy(fds_ptr, fds_copy, fds_size); msg->fds = (int *)fds_ptr; } else { |