From 64eba9a26c6e9236e866b97e2b18e0edb144b187 Mon Sep 17 00:00:00 2001 From: yasuoka Date: Mon, 26 Feb 2024 08:25:51 +0000 Subject: [PATCH] Convert K&R style function declarations to ANSI. --- usr.sbin/npppd/common/addr_range.c | 7 ++- usr.sbin/npppd/common/debugutil.c | 8 ++-- usr.sbin/npppd/common/hash.c | 35 ++++---------- usr.sbin/npppd/common/recvfromto.c | 38 ++++------------ usr.sbin/npppd/npppd/fsm.c | 73 ++++++++---------------------- usr.sbin/npppd/npppd/fsm.h | 4 +- 6 files changed, 44 insertions(+), 121 deletions(-) diff --git a/usr.sbin/npppd/common/addr_range.c b/usr.sbin/npppd/common/addr_range.c index 539a60fb5ef..d81e4b318f1 100644 --- a/usr.sbin/npppd/common/addr_range.c +++ b/usr.sbin/npppd/common/addr_range.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addr_range.c,v 1.6 2017/05/30 17:22:00 yasuoka Exp $ */ +/* $OpenBSD: addr_range.c,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. * All rights reserved. @@ -56,7 +56,7 @@ * Author: * Yasuoka Masahiko * - * $Id: addr_range.c,v 1.6 2017/05/30 17:22:00 yasuoka Exp $ + * $Id: addr_range.c,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ */ #ifdef ADDR_RANGE_DEBUG #define IIJDEBUG @@ -329,8 +329,7 @@ in_addr_range_list_add(struct in_addr_range **list, const char *str) return 0; } -static int bitmask2masklen(mask) - u_int32_t mask; +static int bitmask2masklen(u_int32_t mask) { switch(mask) { case 0x00000000: return 0; diff --git a/usr.sbin/npppd/common/debugutil.c b/usr.sbin/npppd/common/debugutil.c index 7f082abdba4..33c1ce32552 100644 --- a/usr.sbin/npppd/common/debugutil.c +++ b/usr.sbin/npppd/common/debugutil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: debugutil.c,v 1.6 2017/05/30 17:22:00 yasuoka Exp $ */ +/* $OpenBSD: debugutil.c,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. * All rights reserved. @@ -90,15 +90,13 @@ set_prio_idx_init() } void -debug_set_debugfp(fp) - FILE *fp; +debug_set_debugfp(FILE *fp) { debugfp = fp; } void -debug_use_syslog(b) - int b; +debug_use_syslog(int b) { if (b) use_syslog = 1; diff --git a/usr.sbin/npppd/common/hash.c b/usr.sbin/npppd/common/hash.c index 7818b48c6b7..7f5faf199b7 100644 --- a/usr.sbin/npppd/common/hash.c +++ b/usr.sbin/npppd/common/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.5 2015/12/17 08:01:55 tb Exp $ */ +/* $OpenBSD: hash.c,v 1.6 2024/02/26 08:25:51 yasuoka Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. * All rights reserved. @@ -36,10 +36,8 @@ * NULL. */ hash_table * -hash_create(cmp_func, hash_func, hsz) - int (*cmp_func) (const void *, const void *); - uint32_t (*hash_func) (const void *, int); - int hsz; +hash_create(int (*cmp_func) (const void *, const void *), + uint32_t (*hash_func) (const void *, int), int hsz) { hash_table *htbl; @@ -66,8 +64,7 @@ hash_create(cmp_func, hash_func, hsz) * NULL. */ hash_link * -hash_first(htbl) - hash_table *htbl; +hash_first(hash_table *htbl) { htbl->cur = 0; htbl->bucket_cur = NULL; @@ -79,8 +76,7 @@ hash_first(htbl) * NULL. */ hash_link * -hash_next(htbl) - hash_table *htbl; +hash_next(hash_table *htbl) { hash_link *hlink; @@ -105,9 +101,7 @@ hash_next(htbl) * NULL */ hash_link * -hash_lookup(htbl, k) - hash_table *htbl; - const void *k; +hash_lookup(hash_table *htbl, const void *k) { int c; hash_link *w; @@ -125,10 +119,7 @@ hash_lookup(htbl, k) * Return 0 on success. Return -1 on failure. */ int -hash_insert(htbl, k, i) - hash_table *htbl; - const void *k; - void *i; +hash_insert(hash_table *htbl, const void *k, void *i) { int c; hash_link *n; @@ -155,10 +146,7 @@ hash_insert(htbl, k, i) * on failure. */ int -hash_delete(htbl, k, memfree) - hash_table *htbl; - const void *k; - int memfree; +hash_delete(hash_table *htbl, const void *k, int memfree) { int i; hash_link *b, *w; @@ -194,9 +182,7 @@ hash_delete(htbl, k, memfree) * If memfree != 0 then free items. */ void -hash_delete_all(htbl, memfree) - hash_table *htbl; - int memfree; +hash_delete_all(hash_table *htbl, int memfree) { int i; hash_link *w, *hl; @@ -217,8 +203,7 @@ hash_delete_all(htbl, memfree) /* hash_free - Free hash table and all buckets. */ void -hash_free(htbl) - hash_table *htbl; +hash_free(hash_table *htbl) { if (htbl != NULL) { free(htbl->bucket); diff --git a/usr.sbin/npppd/common/recvfromto.c b/usr.sbin/npppd/common/recvfromto.c index fa36f5e4bb1..a4161b470c5 100644 --- a/usr.sbin/npppd/common/recvfromto.c +++ b/usr.sbin/npppd/common/recvfromto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: recvfromto.c,v 1.6 2015/12/17 08:01:55 tb Exp $ */ +/* $OpenBSD: recvfromto.c,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ */ /* adapted from ipsec-tools 0.6 src/racoon/sockmisc.c */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -41,18 +41,9 @@ * setsockopt() have already performed on socket. */ int -recvfromto_nat_t(s, buf, buflen, flags, from, fromlen, to, tolen, - ipsec, ipseclen) - int s; - void *buf; - size_t buflen; - int flags; - struct sockaddr *from; - u_int *fromlen; - struct sockaddr *to; - u_int *tolen; - void *ipsec; - u_int *ipseclen; +recvfromto_nat_t(int s, void *buf, size_t buflen, int flags, + struct sockaddr *from, u_int *fromlen, struct sockaddr *to, u_int *tolen, + void *ipsec, u_int *ipseclen) { int otolen; u_int oipseclen = 0; @@ -188,29 +179,16 @@ recvfromto_nat_t(s, buf, buflen, flags, from, fromlen, to, tolen, } int -recvfromto(s, buf, buflen, flags, from, fromlen, to, tolen) - int s; - void *buf; - size_t buflen; - int flags; - struct sockaddr *from; - u_int *fromlen; - struct sockaddr *to; - u_int *tolen; +recvfromto(int s, void *buf, size_t buflen, int flags, struct sockaddr *from, + u_int *fromlen, struct sockaddr *to, u_int *tolen) { return recvfromto_nat_t(s, buf, buflen, flags, from, fromlen, to, tolen, NULL, NULL); } int -sendto_nat_t(s, buf, buflen, flags, to, tolen, ipsec) - int s; - const void *buf; - size_t buflen; - int flags; - struct sockaddr *to; - u_int tolen; - void *ipsec; +sendto_nat_t(int s, const void *buf, size_t buflen, int flags, + struct sockaddr *to, u_int tolen, void *ipsec) { #ifdef IP_IPSECFLOWINFO if (ipsec) { diff --git a/usr.sbin/npppd/npppd/fsm.c b/usr.sbin/npppd/npppd/fsm.c index 605b7887ed0..c5772d8c09b 100644 --- a/usr.sbin/npppd/npppd/fsm.c +++ b/usr.sbin/npppd/npppd/fsm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fsm.c,v 1.10 2019/02/27 04:52:19 denis Exp $ */ +/* $OpenBSD: fsm.c,v 1.11 2024/02/26 08:25:51 yasuoka Exp $ */ /**@file * This file was adapted from NetBSD:/usr/src/usr.sbin/pppd/pppd/fsm.c @@ -70,7 +70,7 @@ static const char rcsid[] = RCSID; #endif static void fsm_timeout(void *); -static void fsm_rconfreq(fsm *, int, u_char *, int); +static void fsm_rconfreq(fsm *, u_char, u_char *, int len); static void fsm_rconfack(fsm *, int, u_char *, int); static void fsm_rconfnakrej(fsm *, int, int, u_char *, int); static void fsm_rtermreq(fsm *, int, u_char *, int); @@ -96,8 +96,7 @@ fsm_evtimer_timeout(int fd, short evtype, void *ctx) * Initialize fsm state. */ void -fsm_init(f) - fsm *f; +fsm_init(fsm *f) { f->state = INITIAL; f->flags = 0; @@ -116,8 +115,7 @@ fsm_init(f) * fsm_lowerup - The lower layer is up. */ void -fsm_lowerup(f) - fsm *f; +fsm_lowerup(fsm *f) { switch( f->state ){ case INITIAL: @@ -146,8 +144,7 @@ fsm_lowerup(f) * Cancel all timeouts and inform upper layers. */ void -fsm_lowerdown(f) - fsm *f; +fsm_lowerdown(fsm *f) { switch( f->state ){ case CLOSED: @@ -189,8 +186,7 @@ fsm_lowerdown(f) * fsm_open - Link is allowed to come up. */ void -fsm_open(f) - fsm *f; +fsm_open(fsm *f) { switch( f->state ){ case INITIAL: @@ -230,9 +226,7 @@ fsm_open(f) * the CLOSED state. */ void -fsm_close(f, reason) - fsm *f; - const char *reason; +fsm_close(fsm *f, const char *reason) { f->term_reason = (char *)reason; f->term_reason_len = (reason == NULL? 0: strlen(reason)); @@ -273,8 +267,7 @@ fsm_close(f, reason) * fsm_timeout - Timeout expired. */ static void -fsm_timeout(arg) - void *arg; +fsm_timeout(void *arg) { fsm *f = (fsm *) arg; @@ -326,10 +319,7 @@ fsm_timeout(arg) * fsm_input - Input packet. */ void -fsm_input(f, inpacket, l) - fsm *f; - u_char *inpacket; - int l; +fsm_input(fsm *f, u_char *inpacket, int l) { u_char *inp; u_char code, id; @@ -405,11 +395,7 @@ fsm_input(f, inpacket, l) * fsm_rconfreq - Receive Configure-Request. */ static void -fsm_rconfreq(f, id, inp, len) - fsm *f; - u_char id; - u_char *inp; - int len; +fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { int code, reject_if_disagree; @@ -475,11 +461,7 @@ fsm_rconfreq(f, id, inp, len) * fsm_rconfack - Receive Configure-Ack. */ static void -fsm_rconfack(f, id, inp, len) - fsm *f; - int id; - u_char *inp; - int len; +fsm_rconfack(fsm *f, int id, u_char *inp, int len) { if (id != f->reqid || f->seen_ack) /* Expected id? */ return; /* Nope, toss... */ @@ -532,11 +514,7 @@ fsm_rconfack(f, id, inp, len) * fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. */ static void -fsm_rconfnakrej(f, code, id, inp, len) - fsm *f; - int code, id; - u_char *inp; - int len; +fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) { int (*proc)(fsm *, u_char *, int); int ret; @@ -590,11 +568,7 @@ fsm_rconfnakrej(f, code, id, inp, len) * fsm_rtermreq - Receive Terminate-Req. */ static void -fsm_rtermreq(f, id, p, len) - fsm *f; - int id; - u_char *p; - int len; +fsm_rtermreq(fsm *f, int id, u_char *p, int len) { switch (f->state) { case ACKRCVD: @@ -620,8 +594,7 @@ fsm_rtermreq(f, id, p, len) * fsm_rtermack - Receive Terminate-Ack. */ static void -fsm_rtermack(f) - fsm *f; +fsm_rtermack(fsm *f) { switch (f->state) { case CLOSING: @@ -655,10 +628,7 @@ fsm_rtermack(f) * fsm_rcoderej - Receive an Code-Reject. */ static void -fsm_rcoderej(f, inp, len) - fsm *f; - u_char *inp; - int len; +fsm_rcoderej(fsm *f, u_char *inp, int len) { u_char code, id; @@ -683,8 +653,7 @@ fsm_rcoderej(f, inp, len) * Treat this as a catastrophic error (RXJ-). */ void -fsm_protreject(f) - fsm *f; +fsm_protreject(fsm *f) { switch( f->state ){ case CLOSING: @@ -733,9 +702,7 @@ fsm_protreject(f) * fsm_sconfreq - Send a Configure-Request. */ static void -fsm_sconfreq(f, retransmit) - fsm *f; - int retransmit; +fsm_sconfreq(fsm *f, int retransmit) { u_char *outp; int cilen; @@ -783,11 +750,7 @@ fsm_sconfreq(f, retransmit) * Used for all packets sent to our peer by this module. */ void -fsm_sdata(f, code, id, data, datalen) - fsm *f; - u_char code, id; - u_char *data; - int datalen; +fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen) { ppp_output(f->ppp, f->protocol, code, id, data, datalen); } diff --git a/usr.sbin/npppd/npppd/fsm.h b/usr.sbin/npppd/npppd/fsm.h index e793e792b63..8fea751ceee 100644 --- a/usr.sbin/npppd/npppd/fsm.h +++ b/usr.sbin/npppd/npppd/fsm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fsm.h,v 1.6 2017/05/30 17:22:00 yasuoka Exp $ */ +/* $OpenBSD: fsm.h,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ */ /* $NetBSD: fsm.h,v 1.10 2000/09/23 22:39:35 christos Exp $ */ /* @@ -158,7 +158,7 @@ void fsm_open(fsm *); void fsm_close(fsm *, const char *); void fsm_input(fsm *, u_char *, int); void fsm_protreject(fsm *); -void fsm_sdata(fsm *, int, int, u_char *, int); +void fsm_sdata(fsm *, u_char, u_char, u_char *, int); void fsm_log(fsm *, uint32_t, const char *, ...) __attribute__((__format__ (__printf__, 3, 4))); -- 2.20.1