summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-11-20 01:10:10 -0800
committerJune McEnroe <june@causal.agency>2019-11-20 15:23:46 -0500
commitd6055480175938d9d8d968db326469833cff5bf3 (patch)
tree4748ef07aff9f263ace5e29054284dba5e4cd19e
parentclient: Include time.h for gmtime and strftime (diff)
downloadpounce-d6055480175938d9d8d968db326469833cff5bf3.tar.gz
pounce-d6055480175938d9d8d968db326469833cff5bf3.zip
Avoid a couple VLAs with constant size
These are really just regular arrays masquerading as VLAs.
Diffstat (limited to '')
-rw-r--r--dispatch.c5
-rw-r--r--local.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/dispatch.c b/dispatch.c
index d762105..c2e2d50 100644
--- a/dispatch.c
+++ b/dispatch.c
@@ -58,8 +58,7 @@ static void eventRemove(size_t i) {
 }
 
 static ssize_t sendfd(int sock, int fd) {
-	size_t len = CMSG_SPACE(sizeof(int));
-	char buf[len];
+	char buf[CMSG_SPACE(sizeof(int))];
 
 	char x = 0;
 	struct iovec iov = { .iov_base = &x, .iov_len = 1 };
@@ -67,7 +66,7 @@ static ssize_t sendfd(int sock, int fd) {
 		.msg_iov = &iov,
 		.msg_iovlen = 1,
 		.msg_control = buf,
-		.msg_controllen = len,
+		.msg_controllen = sizeof(buf),
 	};
 
 	struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
diff --git a/local.c b/local.c
index 6ef452b..c147259 100644
--- a/local.c
+++ b/local.c
@@ -165,8 +165,7 @@ size_t localUnix(int fds[], size_t cap, const char *path) {
 }
 
 static int recvfd(int sock) {
-	size_t len = CMSG_SPACE(sizeof(int));
-	char buf[len];
+	char buf[CMSG_SPACE(sizeof(int))];
 
 	char x;
 	struct iovec iov = { .iov_base = &x, .iov_len = 1 };
@@ -174,7 +173,7 @@ static int recvfd(int sock) {
 		.msg_iov = &iov,
 		.msg_iovlen = 1,
 		.msg_control = buf,
-		.msg_controllen = len,
+		.msg_controllen = sizeof(buf),
 	};
 	if (0 > recvmsg(sock, &msg, 0)) return -1;