]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
pknlusr: tidy up initialization of local address
authorJeremy Sowden <jeremy@azazel.net>
Sun, 25 Oct 2020 13:15:50 +0000 (14:15 +0100)
committerJan Engelhardt <jengelh@inai.de>
Sun, 25 Oct 2020 13:54:40 +0000 (14:54 +0100)
Use struct initialization and drop memset. We do not need to set the port
ID, since the kernel will do it for us.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
extensions/pknock/pknlusr.c

index 71341cff1d62b8e744fba435d9723688d574b698..b53dc648515ea1cd5052a0e4877e3b2dd4603656 100644 (file)
@@ -16,7 +16,7 @@ int main(void)
 {
        int status;
        int group = GROUP;
-       struct sockaddr_nl local_addr;
+       struct sockaddr_nl local_addr = {.nl_family = AF_NETLINK};
        int sock_fd, buf_size;
        unsigned char *buf;
 
@@ -27,9 +27,6 @@ int main(void)
                return 1;
        }
 
-       memset(&local_addr, 0, sizeof(local_addr));
-       local_addr.nl_family = AF_NETLINK;
-       local_addr.nl_pid = getpid();
        local_addr.nl_groups = group;
        status = bind(sock_fd, (struct sockaddr *)&local_addr, sizeof(local_addr));
        if (status == -1) {