mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-24 11:29:10 +00:00
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
This commit is contained in:
parent
7f719ba784
commit
22efc80fd8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200354
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user