Browse Source

Avoid a couple VLAs with constant size

These are really just regular arrays masquerading as VLAs.
tags/1.0p1
Michael Forney 2 weeks ago
parent
commit
d605548017
Signed by: C. McEnroe <june@causal.agency> GPG Key ID: CEA2F97ADCFCD77C
2 changed files with 4 additions and 6 deletions
  1. +2
    -3
      dispatch.c
  2. +2
    -3
      local.c

+ 2
- 3
dispatch.c View File

@@ -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);

+ 2
- 3
local.c View File

@@ -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;


Loading…
Cancel
Save