PERFORCE change 100495 for review
Paolo Pisati
piso at FreeBSD.org
Mon Jul 3 13:20:53 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=100495
Change 100495 by piso at 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 <sys/types.h>
-#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
More information about the p4-projects
mailing list