From: Jeremy Sowden Date: Sun, 25 Oct 2020 13:15:49 +0000 (+0100) Subject: pknock: pknlusr: tighten up variable scopes X-Git-Tag: v3.12~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4faa4de659d44457a64fe151359448446e606ac;p=thirdparty%2Fxtables-addons.git pknock: pknlusr: tighten up variable scopes Make global variables local, and move variables local to while-loop into the loop. Signed-off-by: Jeremy Sowden --- diff --git a/extensions/pknock/pknlusr.c b/extensions/pknock/pknlusr.c index 84b72ed..71341cf 100644 --- a/extensions/pknock/pknlusr.c +++ b/extensions/pknock/pknlusr.c @@ -12,22 +12,13 @@ #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);