]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
pknock: pknlusr: tighten up variable scopes
authorJeremy Sowden <jeremy@azazel.net>
Sun, 25 Oct 2020 13:15:49 +0000 (14:15 +0100)
committerJan Engelhardt <jengelh@inai.de>
Sun, 25 Oct 2020 13:54:10 +0000 (14:54 +0100)
Make global variables local, and move variables local to while-loop into
the loop.

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

index 84b72edd0b26105b93a973dd5b978ffd09feaf14..71341cff1d62b8e744fba435d9723688d574b698 100644 (file)
 
 #define GROUP 1
 
-static struct sockaddr_nl local_addr;
-static int sock_fd;
-
-static unsigned char *buf;
-
-static struct xt_pknock_nl_msg *nlmsg;
-
 int main(void)
 {
        int status;
        int group = GROUP;
-
-       int buf_size;
-
-       const char *ip;
-       char ipbuf[48];
+       struct sockaddr_nl local_addr;
+       int sock_fd, buf_size;
+       unsigned char *buf;
 
        sock_fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
 
@@ -56,6 +47,9 @@ int main(void)
        }
 
        while(1) {
+               struct xt_pknock_nl_msg *nlmsg;
+               const char *ip;
+               char ipbuf[48];
 
                memset(buf, 0, buf_size);
                status = recv(sock_fd, buf, buf_size, 0);