This is a discussion on small source code beautification within the mailing.openbsd.tech forums, part of the OpenBSD category; --> Hi, the patch below should be a partial beautification of code under /usr/src/sys/net. It's mostly mechanic, but compiled on ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, the patch below should be a partial beautification of code under /usr/src/sys/net. It's mostly mechanic, but compiled on my box. Best, --Toni++ Index: radix.c ================================================== ================= RCS file: /cvs/src/sys/net/radix.c,v retrieving revision 1.18 diff -u -r1.18 radix.c --- radix.c 25 Apr 2004 20:02:39 -0000 1.18 +++ radix.c 10 May 2005 21:30:10 -0000 @@ -105,9 +105,7 @@ */ struct radix_node * -rn_search(v_arg, head) - void *v_arg; - struct radix_node *head; +rn_search (void *v_arg, struct radix_node *head) { struct radix_node *x; caddr_t v; @@ -122,9 +120,7 @@ } struct radix_node * -rn_search_m(v_arg, head, m_arg) - struct radix_node *head; - void *v_arg, *m_arg; +rn_search_m (void *v_arg, struct radix_node *head, void *m_arg) { struct radix_node *x; caddr_t v = v_arg, m = m_arg; @@ -140,8 +136,7 @@ } int -rn_refines(m_arg, n_arg) - void *m_arg, *n_arg; +rn_refines (void *m_arg, void *n_arg) { caddr_t m = m_arg, n = n_arg; caddr_t lim, lim2 = lim = n + *(u_char *)n; @@ -167,9 +162,7 @@ } struct radix_node * -rn_lookup(v_arg, m_arg, head) - void *v_arg, *m_arg; - struct radix_node_head *head; +rn_lookup (void *v_arg, void *m_arg, struct radix_node_head *head) { struct radix_node *x; caddr_t netmask = 0; @@ -188,10 +181,7 @@ } static int -rn_satisfies_leaf(trial, leaf, skip) - char *trial; - struct radix_node *leaf; - int skip; +rn_satisfies_leaf (char *trial, struct radix_node *leaf, int skip) { char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask; char *cplim; @@ -209,9 +199,7 @@ } struct radix_node * -rn_match(v_arg, head) - void *v_arg; - struct radix_node_head *head; +rn_match (void *v_arg, struct radix_node_head *head) { caddr_t v = v_arg; struct radix_node *t = head->rnh_treetop, *x; @@ -318,10 +306,7 @@ #endif struct radix_node * -rn_newpair(v, b, nodes) - void *v; - int b; - struct radix_node nodes[2]; +rn_newpair (void *v, int b, struct radix_node nodes[2]) { struct radix_node *tt = nodes, *t = tt + 1; t->rn_b = b; @@ -343,11 +328,8 @@ } struct radix_node * -rn_insert(v_arg, head, dupentry, nodes) - void *v_arg; - struct radix_node_head *head; - int *dupentry; - struct radix_node nodes[2]; +rn_insert (void *v_arg, struct radix_node_head *head, + int *dupentry, struct radix_node nodes[2]) { caddr_t v = v_arg; struct radix_node *top = head->rnh_treetop; @@ -412,9 +394,7 @@ } struct radix_node * -rn_addmask(n_arg, search, skip) - int search, skip; - void *n_arg; +rn_addmask (void *n_arg, int search, int skip) { caddr_t netmask = (caddr_t)n_arg; struct radix_node *x; @@ -486,9 +466,7 @@ } static int /* XXX: arbitrary ordering for non-contiguous masks */ -rn_lexobetter(m_arg, n_arg) - void *m_arg, *n_arg; -{ +rn_lexobetter (void *m_arg, void *n_arg){ u_char *mp = m_arg, *np = n_arg, *lim; if (*mp > *np) @@ -501,9 +479,7 @@ } static struct radix_mask * -rn_new_radix_mask(tt, next) - struct radix_node *tt; - struct radix_mask *next; +rn_new_radix_mask (struct radix_node *tt, struct radix_mask *next) { struct radix_mask *m; @@ -525,10 +501,8 @@ } struct radix_node * -rn_addroute(v_arg, n_arg, head, treenodes) - void *v_arg, *n_arg; - struct radix_node_head *head; - struct radix_node treenodes[2]; +rn_addroute (void *v_arg, void *n_arg, + struct radix_node_head *head, struct radix_node treenodes[2]) { caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg; struct radix_node *t, *x = NULL, *tt; @@ -703,10 +677,8 @@ } struct radix_node * -rn_delete(v_arg, netmask_arg, head, rn) - void *v_arg, *netmask_arg; - struct radix_node_head *head; - struct radix_node *rn; +rn_delete (void *v_arg, void *netmask_arg, struct radix_node_head *head, + struct radix_node *rn) { struct radix_node *t, *p, *x, *tt; struct radix_mask *m, *saved_m, **mp; @@ -915,10 +887,8 @@ } int -rn_walktree(h, f, w) - struct radix_node_head *h; - int (*f)(struct radix_node *, void *); - void *w; +rn_walktree (struct radix_node_head *h, int (*f)(struct radix_node *, void *), + void *w) { int error; struct radix_node *base, *next; @@ -954,9 +924,7 @@ } int -rn_inithead(head, off) - void **head; - int off; +rn_inithead (void **head, int off) { struct radix_node_head *rnh; @@ -970,9 +938,7 @@ } int -rn_inithead0(rnh, off) - struct radix_node_head *rnh; - int off; +rn_inithead0 (struct radix_node_head *rnh, int off) { struct radix_node *t, *tt, *ttt; Index: radix_mpath.c ================================================== ================= RCS file: /cvs/src/sys/net/radix_mpath.c,v retrieving revision 1.2 diff -u -r1.2 radix_mpath.c --- radix_mpath.c 19 Jun 2004 19:55:53 -0000 1.2 +++ radix_mpath.c 10 May 2005 21:30:18 -0000 @@ -52,16 +52,14 @@ static u_int32_t hashjitter; int -rn_mpath_capable(rnh) - struct radix_node_head *rnh; +rn_mpath_capable (struct radix_node_head *rnh) { return rnh->rnh_multipath; } struct radix_node * -rn_mpath_next(rn) - struct radix_node *rn; +rn_mpath_next (struct radix_node *rn) { struct radix_node *next; @@ -75,8 +73,7 @@ } int -rn_mpath_count(rn) - struct radix_node *rn; +rn_mpath_count (struct radix_node *rn) { int i; @@ -87,21 +84,19 @@ } struct rtentry * -rt_mpath_matchgate(rt, gate) - struct rtentry *rt; - struct sockaddr *gate; +rt_mpath_matchgate (struct rtentry *rt, struct sockaddr *gate) { struct radix_node *rn; - if (!rn_mpath_next((struct radix_node *)rt)) + if (!rn_mpath_next((struct radix_node *) rt)) return rt; if (!gate) return NULL; /* beyond here, we use rn as the master copy */ - rn = (struct radix_node *)rt; + rn = (struct radix_node *) rt; do { - rt = (struct rtentry *)rn; + rt = (struct rtentry *) rn; if (rt->rt_gateway->sa_len == gate->sa_len && !memcmp(rt->rt_gateway, gate, gate->sa_len)) break; @@ -116,11 +111,8 @@ * check if we have the same key/mask/gateway on the table already. */ int -rt_mpath_conflict(rnh, rt, netmask, mpathok) - struct radix_node_head *rnh; - struct rtentry *rt; - struct sockaddr *netmask; - int mpathok; +rt_mpath_conflict (struct radix_node_head *rnh, struct rtentry *rt, + struct sockaddr *netmask, int mpathok) { struct radix_node *rn, *rn1; struct rtentry *rt1; @@ -217,9 +209,7 @@ } void -rtalloc_mpath(ro, hash) - struct route *ro; - int hash; +rtalloc_mpath (struct route *ro, int hash) { struct radix_node *rn0, *rn; int n; @@ -261,9 +251,7 @@ } int -rn_mpath_inithead(head, off) - void **head; - int off; +rn_mpath_inithead (void **head, int off) { struct radix_node_head *rnh; Index: route.c ================================================== ================= RCS file: /cvs/src/sys/net/route.c,v retrieving revision 1.50 diff -u -r1.50 route.c --- route.c 16 Sep 2004 22:31:30 -0000 1.50 +++ route.c 10 May 2005 21:30:03 -0000 @@ -171,8 +171,7 @@ #endif void -rtable_init(table) - void **table; +rtable_init (void **table) { struct domain *dom; for (dom = domains; dom != NULL; dom = dom->dom_next) @@ -182,7 +181,7 @@ } void -route_init() +route_init () { pool_init(&rtentry_pool, sizeof(struct rtentry), 0, 0, 0, "rtentpl", NULL); @@ -191,9 +190,7 @@ } void -rtalloc_noclone(ro, howstrict) - struct route *ro; - int howstrict; +rtalloc_noclone (struct route *ro, int howstrict) { if (ro->ro_rt && ro->ro_rt->rt_ifp && (ro->ro_rt->rt_flags & RTF_UP)) return; /* XXX */ @@ -201,9 +198,7 @@ } int -okaytoclone(flags, howstrict) - u_int flags; - int howstrict; +okaytoclone (u_int flags, int howstrict) { if (howstrict == ALL_CLONING) return (1); @@ -213,9 +208,7 @@ } struct rtentry * -rtalloc2(dst, report,howstrict) - struct sockaddr *dst; - int report,howstrict; +rtalloc2 (struct sockaddr *dst, int report, int howstrict) { struct radix_node_head *rnh = rt_tables[dst->sa_family]; struct rtentry *rt; @@ -258,8 +251,7 @@ * Packet routing routines. */ void -rtalloc(ro) - struct route *ro; +rtalloc (struct route *ro) { if (ro->ro_rt && ro->ro_rt->rt_ifp && (ro->ro_rt->rt_flags & RTF_UP)) return; /* XXX */ @@ -267,9 +259,7 @@ } struct rtentry * -rtalloc1(dst, report) - struct sockaddr *dst; - int report; +rtalloc1 (struct sockaddr *dst, int report) { struct radix_node_head *rnh = rt_tables[dst->sa_family]; struct rtentry *rt; @@ -325,8 +315,7 @@ } void -rtfree(rt) - struct rtentry *rt; +rtfree (struct rtentry *rt) { struct ifaddr *ifa; @@ -352,8 +341,7 @@ } void -ifafree(ifa) - struct ifaddr *ifa; +ifafree (struct ifaddr *ifa) { if (ifa == NULL) panic("ifafree"); @@ -372,10 +360,9 @@ * N.B.: must be called at splsoftnet */ void -rtredirect(dst, gateway, netmask, flags, src, rtp) - struct sockaddr *dst, *gateway, *netmask, *src; - int flags; - struct rtentry **rtp; +rtredirect (struct sockaddr *dst, struct sockaddr *gateway, + struct sockaddr *netmask, int flags, struct sockaddr *src, + struct rtentry **rtp) { struct rtentry *rt; int error = 0; @@ -476,8 +463,7 @@ * Delete a route and generate a message */ int -rtdeletemsg(rt) - struct rtentry *rt; +rtdeletemsg (struct rtentry *rt) { int error; struct rt_addrinfo info; @@ -505,13 +491,11 @@ } int -rtflushclone1(rn, arg) - struct radix_node *rn; - void *arg; +rtflushclone1(struct radix_node *rn, void *arg) { struct rtentry *rt, *parent; - rt = (struct rtentry *)rn; + rt = (struct rtentry *) rn; parent = (struct rtentry *)arg; if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent == parent) rtdeletemsg(rt); @@ -519,9 +503,7 @@ } void -rtflushclone(rnh, parent) - struct radix_node_head *rnh; - struct rtentry *parent; +rtflushclone (struct radix_node_head *rnh, struct rtentry *parent) { #ifdef DIAGNOSTIC @@ -537,18 +519,13 @@ * Routing table ioctl interface. */ int -rtioctl(req, data, p) - u_long req; - caddr_t data; - struct proc *p; +rtioctl (u_long req, caddr_t data, struct proc *p) { return (EOPNOTSUPP); } struct ifaddr * -ifa_ifwithroute(flags, dst, gateway) - int flags; - struct sockaddr *dst, *gateway; +ifa_ifwithroute (int flags, struct sockaddr *dst, struct sockaddr *gateway) { struct ifaddr *ifa; @@ -610,10 +587,8 @@ #define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) int -rtrequest(req, dst, gateway, netmask, flags, ret_nrt) - int req, flags; - struct sockaddr *dst, *gateway, *netmask; - struct rtentry **ret_nrt; +rtrequest (int req, struct sockaddr *dst, struct sockaddr *gateway, + struct sockaddr *netmask, int flags, struct rtentry **ret_nrt) { struct rt_addrinfo info; @@ -637,8 +612,7 @@ #define flags info->rti_flags int -rt_getifa(info) - struct rt_addrinfo *info; +rt_getifa (struct rt_addrinfo *info) { struct ifaddr *ifa; int error = 0; @@ -674,10 +648,7 @@ } int -rtrequest1(req, info, ret_nrt) - int req; - struct rt_addrinfo *info; - struct rtentry **ret_nrt; +rtrequest1 (int req, struct rt_addrinfo *info, struct rtentry **ret_nrt) { int s = splsoftnet(); int error = 0; struct rtentry *rt, *crt; @@ -848,9 +819,7 @@ #undef flags int -rt_setgate(rt0, dst, gate) - struct rtentry *rt0; - struct sockaddr *dst, *gate; +rt_setgate (struct rtentry *rt0, struct sockaddr *dst, struct sockaddr *gate) { caddr_t new, old; int dlen = ROUNDUP(dst->sa_len), glen = ROUNDUP(gate->sa_len); @@ -896,8 +865,8 @@ } void -rt_maskedcopy(src, dst, netmask) - struct sockaddr *src, *dst, *netmask; +rt_maskedcopy (struct sockaddr *src, struct sockaddr *dst, + struct sockaddr *netmask) { u_char *cp1 = (u_char *)src; u_char *cp2 = (u_char *)dst; @@ -920,9 +889,7 @@ * for an interface. */ int -rtinit(ifa, cmd, flags) - struct ifaddr *ifa; - int cmd, flags; +rtinit (struct ifaddr *ifa, int cmd, int flags) { struct rtentry *rt; struct sockaddr *dst; @@ -1037,8 +1004,7 @@ } struct rttimer_queue * -rt_timer_queue_create(timeout) - u_int timeout; +rt_timer_queue_create(u_int timeout) { struct rttimer_queue *rtq; @@ -1059,18 +1025,14 @@ } void -rt_timer_queue_change(rtq, timeout) - struct rttimer_queue *rtq; - long timeout; +rt_timer_queue_change (struct rttimer_queue *rtq, long timeout) { rtq->rtq_timeout = timeout; } void -rt_timer_queue_destroy(rtq, destroy) - struct rttimer_queue *rtq; - int destroy; +rt_timer_queue_destroy (struct rttimer_queue *rtq, int destroy) { struct rttimer *r; @@ -1094,16 +1056,14 @@ } unsigned long -rt_timer_count(rtq) - struct rttimer_queue *rtq; +rt_timer_count (struct rttimer_queue *rtq) { return (rtq->rtq_count); } void -rt_timer_remove_all(rt) - struct rtentry *rt; +rt_timer_remove_all (struct rtentry *rt) { struct rttimer *r; @@ -1119,10 +1079,8 @@ } int -rt_timer_add(rt, func, queue) - struct rtentry *rt; - void(*func)(struct rtentry *, struct rttimer *); - struct rttimer_queue *queue; +rt_timer_add (struct rtentry *rt, void (*func)(struct rtentry *, struct rttimer *), + struct rttimer_queue *queue) { struct rttimer *r; long current_time; @@ -1165,8 +1123,7 @@ /* ARGSUSED */ void -rt_timer_timer(arg) - void *arg; +rt_timer_timer (void *arg) { struct timeout *to = (struct timeout *)arg; struct rttimer_queue *rtq; @@ -1197,7 +1154,7 @@ } u_int16_t -rtlabel_name2id(char *name) +rtlabel_name2id (char *name) { struct rt_label *label, *p = NULL; u_int16_t new_id = 1; @@ -1240,7 +1197,7 @@ } const char * -rtlabel_id2name(u_int16_t id) +rtlabel_id2name (u_int16_t id) { struct rt_label *label; @@ -1252,7 +1209,7 @@ } void -rtlabel_unref(u_int16_t id) +rtlabel_unref (u_int16_t id) { struct rt_label *p, *next; |