Use constexpr

This commit is contained in:
Yash Tibrewal 2019-02-11 16:58:24 -08:00
parent 5a44f700bb
commit 6a372ff442
1 changed files with 7 additions and 5 deletions

View File

@ -715,13 +715,15 @@ static void process_errors(grpc_tcp* tcp) {
msg.msg_iovlen = 0;
msg.msg_flags = 0;
/* Allocate enough space so we don't need to keep increasing this as size
* of OPT_STATS increase */
constexpr size_t cmsg_alloc_space =
1024 /*CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) +
CMSG_SPACE(sizeof(sock_extended_err) + sizeof(sockaddr_in)) +
CMSG_SPACE(16 * NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t)))*/;
/* Allocate aligned space for cmsgs received along with timestamps */
union {
/* Allocate enough space so we don't need to keep increasing this as size
* of OPT_STATS increase */
char rbuf[1024 /*CMSG_SPACE(sizeof(grpc_core::scm_timestamping)) +
CMSG_SPACE(sizeof(sock_extended_err) + sizeof(sockaddr_in)) +
CMSG_SPACE(16 * NLA_ALIGN(NLA_HDRLEN + sizeof(uint64_t)))*/];
char rbuf[cmsg_alloc_space];
struct cmsghdr align;
} aligned_buf;
memset(&aligned_buf, 0, sizeof(aligned_buf));