From bef81bc0aef9dd4cd772b292d81bcc0ff7151d9f Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 3 Apr 2023 05:00:25 +0300 Subject: [PATCH] setkey(8): ansify parser Sponsored by: NVidia networking MFC after: 1 week --- sbin/setkey/parse.y | 51 ++++++++++++--------------------------------- sbin/setkey/token.l | 9 +++----- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/sbin/setkey/parse.y b/sbin/setkey/parse.y index 0d8605c3409..3d3ed123d4f 100644 --- a/sbin/setkey/parse.y +++ b/sbin/setkey/parse.y @@ -773,11 +773,7 @@ policy_requests %% int -setkeymsg0(msg, type, satype, l) - struct sadb_msg *msg; - unsigned int type; - unsigned int satype; - size_t l; +setkeymsg0(struct sadb_msg *msg, unsigned type, unsigned satype, size_t l) { msg->sadb_msg_version = PF_KEY_V2; @@ -793,14 +789,8 @@ setkeymsg0(msg, type, satype, l) /* XXX NO BUFFER OVERRUN CHECK! BAD BAD! */ static int -setkeymsg_spdaddr(type, upper, policy, srcs, splen, dsts, dplen) - unsigned int type; - unsigned int upper; - vchar_t *policy; - struct addrinfo *srcs; - int splen; - struct addrinfo *dsts; - int dplen; +setkeymsg_spdaddr(unsigned type, unsigned upper, vchar_t *policy, + struct addrinfo *srcs, int splen, struct addrinfo *dsts, int dplen) { struct sadb_msg *msg; char buf[BUFSIZ]; @@ -892,12 +882,8 @@ setkeymsg_spdaddr(type, upper, policy, srcs, splen, dsts, dplen) /* XXX NO BUFFER OVERRUN CHECK! BAD BAD! */ static int -setkeymsg_addr(type, satype, srcs, dsts, no_spi) - unsigned int type; - unsigned int satype; - struct addrinfo *srcs; - struct addrinfo *dsts; - int no_spi; +setkeymsg_addr(unsigned type, unsigned satype, struct addrinfo *srcs, + struct addrinfo *dsts, int no_spi) { struct sadb_msg *msg; char buf[BUFSIZ]; @@ -1023,11 +1009,8 @@ setkeymsg_addr(type, satype, srcs, dsts, no_spi) /* XXX NO BUFFER OVERRUN CHECK! BAD BAD! */ static int -setkeymsg_add(type, satype, srcs, dsts) - unsigned int type; - unsigned int satype; - struct addrinfo *srcs; - struct addrinfo *dsts; +setkeymsg_add(unsigned type, unsigned satype, struct addrinfo *srcs, + struct addrinfo *dsts) { struct sadb_msg *msg; char buf[BUFSIZ]; @@ -1211,9 +1194,7 @@ setkeymsg_add(type, satype, srcs, dsts) } static struct addrinfo * -parse_addr(host, port) - char *host; - char *port; +parse_addr(char *host, char *port) { struct addrinfo hints, *res = NULL; int error; @@ -1232,8 +1213,7 @@ parse_addr(host, port) } static int -fix_portstr(spec, sport, dport) - vchar_t *spec, *sport, *dport; +fix_portstr(vchar_t *spec, vchar_t *sport, vchar_t *dport) { char *p, *p2; u_int l; @@ -1273,13 +1253,8 @@ fix_portstr(spec, sport, dport) } static int -setvarbuf(buf, off, ebuf, elen, vbuf, vlen) - char *buf; - int *off; - struct sadb_ext *ebuf; - int elen; - caddr_t vbuf; - int vlen; +setvarbuf(char *buf, int *off, struct sadb_ext *ebuf, int elen, caddr_t vbuf, + int vlen) { memset(buf + *off, 0, PFKEY_UNUNIT64(ebuf->sadb_ext_len)); memcpy(buf + *off, (caddr_t)ebuf, elen); @@ -1290,7 +1265,7 @@ setvarbuf(buf, off, ebuf, elen, vbuf, vlen) } void -parse_init() +parse_init(void) { p_spi = 0; @@ -1309,7 +1284,7 @@ parse_init() } void -free_buffer() +free_buffer(void) { /* we got tons of memory leaks in the parser anyways, leave them */ } diff --git a/sbin/setkey/token.l b/sbin/setkey/token.l index 1cf2a43fe32..44b1ffbfaa3 100644 --- a/sbin/setkey/token.l +++ b/sbin/setkey/token.l @@ -253,23 +253,20 @@ any { return(ANY); } %% void -yyfatal(s) - const char *s; +yyfatal(const char *s) { yyerror(s); exit(1); } void -yyerror(s) - const char *s; +yyerror(const char *s) { printf("line %d: %s at [%s]\n", lineno, s, yytext); } int -parse(fp) - FILE **fp; +parse(FILE **fp) { yyin = *fp;