From f3489d5cb77a804891bdaff3d90449fa7f293dd6 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Thu, 8 Oct 2015 03:25:53 +0200 Subject: swrap: Simplify cmspace calculation in swrap_sendmsg_copy_cmsg() With cmsg->cmsg_len = CMSG_LEN(len) => CMSG_ALIGN(cmsg->cmsg_len) = CMSG_ALIGN(CMSG_LEN(len)) = CMSG_ALIGN(CMSG_ALIGN(sizeof(struct cmsghdr)) + len) = CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len) = CMSG_SPACE(len) = CMSG_SPACE(CMSG_ALIGN(sizeof(struct cmsghdr)) + len - CMSG_ALIGN(sizeof(struct cmsghdr))) = CMSG_SPACE(CMSG_LEN(len) - CMSG_ALIGN(sizeof(struct cmsghdr))) = CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))) :) Signed-off-by: Ralph Boehme Reviewed-by: Andreas Schneider --- src/socket_wrapper.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index aad5f3e..353ad1d 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -3739,9 +3739,7 @@ static int swrap_sendmsg_copy_cmsg(struct cmsghdr *cmsg, size_t cmspace; uint8_t *p; - cmspace = - (*cm_data_space) + - CMSG_SPACE(cmsg->cmsg_len - CMSG_ALIGN(sizeof(struct cmsghdr))); + cmspace = *cm_data_space + CMSG_ALIGN(cmsg->cmsg_len); p = realloc((*cm_data), cmspace); if (p == NULL) { -- cgit