From 9cd0b44c81b500fcf87a8b3f1337bfedc20a4305 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Sun, 25 Oct 2020 14:15:50 +0100 Subject: [PATCH] pknlusr: tidy up initialization of local address 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 --- extensions/pknock/pknlusr.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/extensions/pknock/pknlusr.c b/extensions/pknock/pknlusr.c index 71341cf..b53dc64 100644 --- a/extensions/pknock/pknlusr.c +++ b/extensions/pknock/pknlusr.c @@ -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) {