Commit 19c1c991 authored by Jacob Satterfield's avatar Jacob Satterfield Committed by Paul Moore

selinux: simplify avtab_insert_node() prototype

__hashtab_insert() in hashtab.h has a cleaner interface that allows the
caller to specify the chain node location that the new node is being
inserted into so that it can update the node that currently occupies it.
Signed-off-by: default avatarJacob Satterfield <jsatterfield.linux@gmail.com>
Reviewed-by: default avatarStephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 9d140885
...@@ -67,8 +67,7 @@ static inline u32 avtab_hash(const struct avtab_key *keyp, u32 mask) ...@@ -67,8 +67,7 @@ static inline u32 avtab_hash(const struct avtab_key *keyp, u32 mask)
} }
static struct avtab_node* static struct avtab_node*
avtab_insert_node(struct avtab *h, u32 hvalue, avtab_insert_node(struct avtab *h, struct avtab_node **dst,
struct avtab_node *prev,
const struct avtab_key *key, const struct avtab_datum *datum) const struct avtab_key *key, const struct avtab_datum *datum)
{ {
struct avtab_node *newnode; struct avtab_node *newnode;
...@@ -90,15 +89,8 @@ avtab_insert_node(struct avtab *h, u32 hvalue, ...@@ -90,15 +89,8 @@ avtab_insert_node(struct avtab *h, u32 hvalue,
newnode->datum.u.data = datum->u.data; newnode->datum.u.data = datum->u.data;
} }
if (prev) { newnode->next = *dst;
newnode->next = prev->next; *dst = newnode;
prev->next = newnode;
} else {
struct avtab_node **n = &h->htable[hvalue];
newnode->next = *n;
*n = newnode;
}
h->nel++; h->nel++;
return newnode; return newnode;
...@@ -138,7 +130,8 @@ static int avtab_insert(struct avtab *h, const struct avtab_key *key, ...@@ -138,7 +130,8 @@ static int avtab_insert(struct avtab *h, const struct avtab_key *key,
break; break;
} }
newnode = avtab_insert_node(h, hvalue, prev, key, datum); newnode = avtab_insert_node(h, prev ? &prev->next : &h->htable[hvalue],
key, datum);
if (!newnode) if (!newnode)
return -ENOMEM; return -ENOMEM;
...@@ -178,7 +171,8 @@ struct avtab_node *avtab_insert_nonunique(struct avtab *h, ...@@ -178,7 +171,8 @@ struct avtab_node *avtab_insert_nonunique(struct avtab *h,
key->target_class < cur->key.target_class) key->target_class < cur->key.target_class)
break; break;
} }
return avtab_insert_node(h, hvalue, prev, key, datum); return avtab_insert_node(h, prev ? &prev->next : &h->htable[hvalue],
key, datum);
} }
/* This search function returns a node pointer, and can be used in /* This search function returns a node pointer, and can be used in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment