1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
From ab8a58c777d6bc3e33b1f28c80fa5bbada804a4b Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Sun, 16 Jun 2019 13:38:59 -0700
Subject: [PATCH] Avoid unnecessary VLAs
---
include/bpf_scm.h | 2 +-
ip/iptuntap.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/include/bpf_scm.h b/include/bpf_scm.h
index 669f0538..9e456030 100644
--- a/include/bpf_scm.h
+++ b/include/bpf_scm.h
@@ -37,7 +37,7 @@ static inline int *bpf_map_set_init(struct bpf_map_set_msg *msg,
struct sockaddr_un *addr,
unsigned int addr_len)
{
- const unsigned int cmsg_ctl_len = sizeof(int) * BPF_SCM_MAX_FDS;
+ enum { cmsg_ctl_len = sizeof(int) * BPF_SCM_MAX_FDS };
struct cmsghdr *cmsg;
msg->iov.iov_base = &msg->aux;
diff --git a/ip/iptuntap.c b/ip/iptuntap.c
index 3cf55055..e149ae16 100644
--- a/ip/iptuntap.c
+++ b/ip/iptuntap.c
@@ -270,8 +270,7 @@ static void show_processes(const char *name)
fd_path = globbuf.gl_pathv;
while (*fd_path) {
- const size_t linkbuf_len = strlen(TUNDEV) + 2;
- char linkbuf[linkbuf_len], *fdinfo;
+ char linkbuf[sizeof(TUNDEV) + 1], *fdinfo;
int pid, fd;
FILE *f;
@@ -281,7 +280,7 @@ static void show_processes(const char *name)
if (pid == getpid())
goto next;
- err = readlink(*fd_path, linkbuf, linkbuf_len - 1);
+ err = readlink(*fd_path, linkbuf, sizeof(linkbuf) - 1);
if (err < 0) {
perror("readlink");
goto next;
--
2.44.0
|