Commit 83e7e18e authored by Christian Göttsche's avatar Christian Göttsche Committed by Paul Moore
Browse files

selinux: rename comparison functions for clarity



The functions context_cmp(), mls_context_cmp() and ebitmap_cmp() are not
traditional C style compare functions returning -1, 0, and 1 for less
than, equal, and greater than; they only return whether their arguments
are equal.

Signed-off-by: default avatarChristian Göttsche <cgzones@googlemail.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 5e99b81f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ u32 context_compute_hash(const struct context *c)
	 * context struct with only the len & str set (and vice versa)
	 * under a given policy. Since context structs from different
	 * policies should never meet, it is safe to hash valid and
	 * invalid contexts differently. The context_cmp() function
	 * invalid contexts differently. The context_equal() function
	 * already operates under the same assumption.
	 */
	if (c->len)
+7 −7
Original line number Diff line number Diff line
@@ -132,13 +132,13 @@ static inline int mls_context_glblub(struct context *dst,
	return rc;
}

static inline int mls_context_cmp(const struct context *c1,
static inline bool mls_context_equal(const struct context *c1,
				     const struct context *c2)
{
	return ((c1->range.level[0].sens == c2->range.level[0].sens) &&
		ebitmap_cmp(&c1->range.level[0].cat, &c2->range.level[0].cat) &&
		ebitmap_equal(&c1->range.level[0].cat, &c2->range.level[0].cat) &&
		(c1->range.level[1].sens == c2->range.level[1].sens) &&
		ebitmap_cmp(&c1->range.level[1].cat, &c2->range.level[1].cat));
		ebitmap_equal(&c1->range.level[1].cat, &c2->range.level[1].cat));
}

static inline void mls_context_destroy(struct context *c)
@@ -188,7 +188,7 @@ static inline void context_destroy(struct context *c)
	mls_context_destroy(c);
}

static inline int context_cmp(const struct context *c1,
static inline bool context_equal(const struct context *c1,
				 const struct context *c2)
{
	if (c1->len && c2->len)
@@ -196,7 +196,7 @@ static inline int context_cmp(const struct context *c1,
	if (c1->len || c2->len)
		return 0;
	return ((c1->user == c2->user) && (c1->role == c2->role) &&
		(c1->type == c2->type) && mls_context_cmp(c1, c2));
		(c1->type == c2->type) && mls_context_equal(c1, c2));
}

u32 context_compute_hash(const struct context *c);
+4 −4
Original line number Diff line number Diff line
@@ -25,12 +25,12 @@

static struct kmem_cache *ebitmap_node_cachep __ro_after_init;

int ebitmap_cmp(const struct ebitmap *e1, const struct ebitmap *e2)
bool ebitmap_equal(const struct ebitmap *e1, const struct ebitmap *e2)
{
	const struct ebitmap_node *n1, *n2;

	if (e1->highbit != e2->highbit)
		return 0;
		return false;

	n1 = e1->node;
	n2 = e2->node;
@@ -41,9 +41,9 @@ int ebitmap_cmp(const struct ebitmap *e1, const struct ebitmap *e2)
	}

	if (n1 || n2)
		return 0;
		return false;

	return 1;
	return true;
}

int ebitmap_cpy(struct ebitmap *dst, const struct ebitmap *src)
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ static inline void ebitmap_node_clr_bit(struct ebitmap_node *n, u32 bit)
	     (bit) < ebitmap_length(e);               \
	     (bit) = ebitmap_next_positive(e, &(n), bit))

int ebitmap_cmp(const struct ebitmap *e1, const struct ebitmap *e2);
bool ebitmap_equal(const struct ebitmap *e1, const struct ebitmap *e2);
int ebitmap_cpy(struct ebitmap *dst, const struct ebitmap *src);
int ebitmap_and(struct ebitmap *dst, const struct ebitmap *e1,
		const struct ebitmap *e2);
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ struct mls_range {
static inline int mls_level_eq(const struct mls_level *l1,
			       const struct mls_level *l2)
{
	return ((l1->sens == l2->sens) && ebitmap_cmp(&l1->cat, &l2->cat));
	return ((l1->sens == l2->sens) && ebitmap_equal(&l1->cat, &l2->cat));
}

static inline int mls_level_dom(const struct mls_level *l1,
Loading