aboutsummaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorLuigi Rizzo <luigi@FreeBSD.org>2009-12-10 10:34:30 +0000
committerLuigi Rizzo <luigi@FreeBSD.org>2009-12-10 10:34:30 +0000
commit22efc80fd8c885d46fc7c6b5e16df315cfe73768 (patch)
tree014743ad58ac7dd91362f5e66ef42988da9f0ea8 /sys/net
parent7f719ba784cd8534cfecfd8d8733df19295219e6 (diff)
downloadsrc-22efc80fd8c885d46fc7c6b5e16df315cfe73768.tar.gz
src-22efc80fd8c885d46fc7c6b5e16df315cfe73768.zip
No functional changes (who dares to touch this code!) but:
- cast the result of LEN() to int as this is the main usage. - use LEN() in one place where it was forgotten. - Document the use of a static variable in rw mode. More small changes to follow. MFC after: 7 days
Notes
Notes: svn path=/head/; revision=200354
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/radix.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/net/radix.c b/sys/net/radix.c
index 39b198eaf49e..a494adf10c78 100644
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -72,6 +72,8 @@ static struct radix_node_head *mask_rnhead;
/*
* Work area -- the following point to 3 buffers of size max_keylen,
* allocated in this order in a block of memory malloc'ed by rn_init.
+ * rn_zeros, rn_ones are set in rn_init and used in readonly afterwards.
+ * addmask_key is used in rn_addmask in rw mode and not thread-safe.
*/
static char *rn_zeros, *rn_ones, *addmask_key;
@@ -135,8 +137,9 @@ static int rn_satisfies_leaf(char *trial, struct radix_node *leaf,
* To make the assumption more explicit, we use the LEN() macro to access
* this field. It is safe to pass an expression with side effects
* to LEN() as the argument is evaluated only once.
+ * We cast the result to int as this is the dominant usage.
*/
-#define LEN(x) (*(const u_char *)(x))
+#define LEN(x) ( (int) (*(const u_char *)(x)) )
/*
* XXX THIS NEEDS TO BE FIXED
@@ -197,7 +200,7 @@ rn_refines(m_arg, n_arg)
{
register caddr_t m = m_arg, n = n_arg;
register caddr_t lim, lim2 = lim = n + LEN(n);
- int longer = LEN(n++) - (int)LEN(m++);
+ int longer = LEN(n++) - LEN(m++);
int masks_are_equal = 1;
if (longer > 0)
@@ -250,10 +253,10 @@ rn_satisfies_leaf(trial, leaf, skip)
char *cplim;
int length = min(LEN(cp), LEN(cp2));
- if (cp3 == 0)
+ if (cp3 == NULL)
cp3 = rn_ones;
else
- length = min(length, *(u_char *)cp3);
+ length = min(length, LEN(cp3));
cplim = cp + length; cp3 += skip; cp2 += skip;
for (cp += skip; cp < cplim; cp++, cp2++, cp3++)
if ((*cp ^ *cp2) & *cp3)
@@ -424,7 +427,7 @@ rn_insert(v_arg, head, dupentry, nodes)
{
caddr_t v = v_arg;
struct radix_node *top = head->rnh_treetop;
- int head_off = top->rn_offset, vlen = (int)LEN(v);
+ int head_off = top->rn_offset, vlen = LEN(v);
register struct radix_node *t = rn_search(v_arg, top);
register caddr_t cp = v + head_off;
register int b;