From owner-p4-projects@FreeBSD.ORG Mon Jul 3 13:20:53 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id A845016A54E; Mon, 3 Jul 2006 13:20:52 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5653D16A532 for ; Mon, 3 Jul 2006 13:20:52 +0000 (UTC) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id DE20F442A2 for ; Mon, 3 Jul 2006 13:03:52 +0000 (GMT) (envelope-from piso@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k63D3qjw091174 for ; Mon, 3 Jul 2006 13:03:52 GMT (envelope-from piso@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k63D3qbr091171 for perforce@freebsd.org; Mon, 3 Jul 2006 13:03:52 GMT (envelope-from piso@freebsd.org) Date: Mon, 3 Jul 2006 13:03:52 GMT Message-Id: <200607031303.k63D3qbr091171@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to piso@freebsd.org using -f From: Paolo Pisati To: Perforce Change Reviews Cc: Subject: PERFORCE change 100495 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jul 2006 13:20:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=100495 Change 100495 by piso@piso_newluxor on 2006/07/03 13:02:52 Apply style(9): -axe #if __FreeBSD_version ... #endif stuff -sanitize comments -convert all vars named 'err' to 'error' -put some XXX around for later work Affected files ... .. //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#2 edit Differences ... ==== //depot/projects/soc2005/libalias/sys/netinet/libalias/alias_mod.c#2 (text+ko) ==== @@ -56,20 +56,15 @@ #include -#if __FreeBSD_version >= 500000 /* XXX - make the compiler happy... */ int strncmp(const char *s1, const char *s2, size_t len); -#endif -/* protocol and userland module handlers chains */ +/* Protocol and userland module handlers chains. */ struct chain handler_chain, dll_chain; +// XXX - use queue(3) and errno.h #ifdef _KERNEL -#if __FreeBSD_version >= 500000 - -/* Fine grained locking for 5.x, 6.x and 7.x */ - #define LIBALIAS_LOCK_INIT(_chain) \ mtx_init(&(_chain)->mtx, "libalias list of proto-handlers", NULL, \ MTX_DEF | MTX_RECURSE) @@ -127,59 +122,9 @@ if (mtx_initialized(&c->mtx)) LIBALIAS_LOCK_DESTROY(c); } -#else -/* Good old spl*() locking for 4.x */ -/* - * XXX - i'm not sure about mutex & conditional var - * conversion that i did using spl*()... - */ - -#define LIBALIAS_LOCK_INIT(_chain) (_chain)->spl = 0 -#define LIBALIAS_LOCK_DESTROY(_chain) -#define LIBALIAS_WLOCK_ASSERT(_chain) do { \ - KASSERT(_chain->spl != 0, ("chain not locked")); \ -} while (0) - -static __inline void -LIBALIAS_RLOCK(struct chain *chain) -{ - chain->spl = splimp(); -} - -static __inline void -LIBALIAS_RUNLOCK(struct chain *chain) -{ - splx(chain->spl); -} - -static __inline void -LIBALIAS_WLOCK(struct chain *chain) -{ - LIBALIAS_RLOCK(chain); -} - -static __inline void -LIBALIAS_WUNLOCK(struct chain *chain) -{ - LIBALIAS_RUNLOCK(chain); -} - -static void -_handler_chain_init(struct chain *c) { +#else - c->spl = 0; -} - -static void -_handler_chain_destroy(struct chain *c) { - - ; -} - -#endif -#else - #define LIBALIAS_LOCK_INIT(_chain) ; #define LIBALIAS_LOCK_DESTROY(_chain) ; #define LIBALIAS_WLOCK_ASSERT(_chain) ; @@ -237,16 +182,16 @@ LIBALIAS_WLOCK_ASSERT(c); b = (struct proto_handler **)&c->chain; - p->next = NULL; /* i'm paranoid... */ + p->next = NULL; /* I'm paranoid... */ for(; *b != NULL; b = &((*b)->next), i++) { if (((*b)->pri == p->pri) && ((*b)->dir == p->dir) && ((*b)->proto == p->proto)) - return (EHDCON); /* priority conflict */ + return (EHDCON); /* Priority conflict. */ if ((*b)->pri > p->pri) { p->next = *b; break; } } - /* end of list or got right position, insert here */ + /* End of list or got right position, insert here. */ *b = p; return (OK); } @@ -260,13 +205,13 @@ for(; (*b != NULL) && (*b != p); b = &((*b)->next)) ; if (*b == p) *b = p->next; - else return (EHDNOF); /* handler not found */ + else return (EHDNOF); /* Handler not found. */ return (OK); } int attach_handlers(struct proto_handler *_p) { - int i, res = NOK; + int i, error = NOK; LIBALIAS_WLOCK(&handler_chain); for (i=0; 1; i++) { @@ -275,12 +220,12 @@ if (res != OK) break; } LIBALIAS_WUNLOCK(&handler_chain); - return (res); + return (error); } int detach_handlers(struct proto_handler *_p) { - int i, res = NOK; + int i, error = NOK; LIBALIAS_WLOCK(&handler_chain); for (i=0; 1; i++) { @@ -289,23 +234,23 @@ if (res != OK) break; } LIBALIAS_WUNLOCK(&handler_chain); - return (res); + return (error); } int detach_handler(struct proto_handler *_p) { - int res = NOK; + int error = NOK; LIBALIAS_WLOCK(&handler_chain); res = _detach_handler(&handler_chain, _p); LIBALIAS_WUNLOCK(&handler_chain); - return (res); + return (error); } int find_handler(int8_t dir, int8_t proto, struct libalias *la, struct ip *pip, struct alias_data *ad) { struct proto_handler *p; - int err; + int error; LIBALIAS_RLOCK(&handler_chain); for (p = handler_chain.chain, err = EHDNOF; p != NULL; p = p->next) @@ -315,7 +260,7 @@ break; } LIBALIAS_RUNLOCK(&handler_chain); - return (err); + return (error); } struct proto_handler * @@ -331,11 +276,11 @@ LIBALIAS_WLOCK_ASSERT(c); b = (struct dll **)&c->chain; - p->next = NULL; /* i'm paranoid... */ + p->next = NULL; /* I'm paranoid... */ for(; *b != NULL; b = &((*b)->next), i++) if (!strncmp((*b)->name, p->name, DLL_LEN)) - return (EHDCON); /* dll name conflict */ - /* end of list, insert here */ + return (EHDCON); /* Dll name conflict. */ + /* End of list, insert here. */ *b = p; return (OK); } @@ -343,17 +288,17 @@ static void * _detach_dll(struct chain *c, char *p) { struct dll **b; - void *err = NULL; + void *error = NULL; LIBALIAS_WLOCK_ASSERT(c); b = (struct dll **)&c->chain; for(; *b != NULL; b = &((*b)->next)) if (!strncmp((*b)->name, p, DLL_LEN)) { - err = *b; + error = *b; *b = (*b)->next; break; } - return (err); + return (error); } int