]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Remove needless malloc
authorRoy Marples <roy@marples.name>
Wed, 12 Feb 2014 10:27:29 +0000 (10:27 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Feb 2014 10:27:29 +0000 (10:27 +0000)
bpf.c

diff --git a/bpf.c b/bpf.c
index 96e07ce68dc5d48c19287b5f1c054372e7e5c65d..6617f060bfa3608e315c5d4b51d756d3fadeb2a3 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -64,17 +64,13 @@ ipv4_opensocket(struct interface *ifp, int protocol)
 #ifdef _PATH_BPF
        fd = open(_PATH_BPF, O_RDWR | O_CLOEXEC | O_NONBLOCK);
 #else
-       char *device;
+       char device[PATH_MAX];
        int n = 0;
 
-       device = malloc(sizeof(char) * PATH_MAX);
-       if (device == NULL)
-               return -1;
        do {
                snprintf(device, PATH_MAX, "/dev/bpf%d", n++);
                fd = open(device, O_RDWR | O_CLOEXEC | O_NONBLOCK);
        } while (fd == -1 && errno == EBUSY);
-       free(device);
 #endif
 
        if (fd == -1)