mirror of
https://github.com/SELinuxProject/selinux
synced 2024-12-14 10:05:02 +00:00
libsepol: mark read-only parameters of ebitmap interfaces const
Make it more obvious which parameters are read-only and not being modified and allow callers to pass const pointers. Signed-off-by: Christian Göttsche <cgzones@googlemail.com> Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
parent
a53a845b76
commit
390ec54d27
@ -67,7 +67,7 @@ static inline unsigned int ebitmap_next(ebitmap_node_t ** n, unsigned int bit)
|
||||
return (bit + 1);
|
||||
}
|
||||
|
||||
static inline int ebitmap_node_get_bit(ebitmap_node_t * n, unsigned int bit)
|
||||
static inline int ebitmap_node_get_bit(const ebitmap_node_t * n, unsigned int bit)
|
||||
{
|
||||
if (n->map & (MAPBIT << (bit - n->startbit)))
|
||||
return 1;
|
||||
@ -83,18 +83,18 @@ static inline int ebitmap_node_get_bit(ebitmap_node_t * n, unsigned int bit)
|
||||
extern int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2);
|
||||
extern int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2);
|
||||
extern int ebitmap_union(ebitmap_t * dst, const ebitmap_t * e1);
|
||||
extern int ebitmap_and(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2);
|
||||
extern int ebitmap_xor(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2);
|
||||
extern int ebitmap_not(ebitmap_t *dst, ebitmap_t *e1, unsigned int maxbit);
|
||||
extern int ebitmap_andnot(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2, unsigned int maxbit);
|
||||
extern unsigned int ebitmap_cardinality(ebitmap_t *e1);
|
||||
extern int ebitmap_hamming_distance(ebitmap_t * e1, ebitmap_t * e2);
|
||||
extern int ebitmap_and(ebitmap_t *dst, const ebitmap_t *e1, const ebitmap_t *e2);
|
||||
extern int ebitmap_xor(ebitmap_t *dst, const ebitmap_t *e1, const ebitmap_t *e2);
|
||||
extern int ebitmap_not(ebitmap_t *dst, const ebitmap_t *e1, unsigned int maxbit);
|
||||
extern int ebitmap_andnot(ebitmap_t *dst, const ebitmap_t *e1, const ebitmap_t *e2, unsigned int maxbit);
|
||||
extern unsigned int ebitmap_cardinality(const ebitmap_t *e1);
|
||||
extern int ebitmap_hamming_distance(const ebitmap_t * e1, const ebitmap_t * e2);
|
||||
extern int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src);
|
||||
extern int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2);
|
||||
extern int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2);
|
||||
extern int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit);
|
||||
extern int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value);
|
||||
extern unsigned int ebitmap_highest_set_bit(ebitmap_t * e);
|
||||
extern unsigned int ebitmap_highest_set_bit(const ebitmap_t * e);
|
||||
extern void ebitmap_destroy(ebitmap_t * e);
|
||||
extern int ebitmap_read(ebitmap_t * e, void *fp);
|
||||
|
||||
|
@ -71,7 +71,7 @@ int ebitmap_union(ebitmap_t * dst, const ebitmap_t * e1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ebitmap_and(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2)
|
||||
int ebitmap_and(ebitmap_t *dst, const ebitmap_t *e1, const ebitmap_t *e2)
|
||||
{
|
||||
unsigned int i, length = min(ebitmap_length(e1), ebitmap_length(e2));
|
||||
ebitmap_init(dst);
|
||||
@ -85,7 +85,7 @@ int ebitmap_and(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ebitmap_xor(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2)
|
||||
int ebitmap_xor(ebitmap_t *dst, const ebitmap_t *e1, const ebitmap_t *e2)
|
||||
{
|
||||
unsigned int i, length = max(ebitmap_length(e1), ebitmap_length(e2));
|
||||
ebitmap_init(dst);
|
||||
@ -98,7 +98,7 @@ int ebitmap_xor(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ebitmap_not(ebitmap_t *dst, ebitmap_t *e1, unsigned int maxbit)
|
||||
int ebitmap_not(ebitmap_t *dst, const ebitmap_t *e1, unsigned int maxbit)
|
||||
{
|
||||
unsigned int i;
|
||||
ebitmap_init(dst);
|
||||
@ -111,7 +111,7 @@ int ebitmap_not(ebitmap_t *dst, ebitmap_t *e1, unsigned int maxbit)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ebitmap_andnot(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2, unsigned int maxbit)
|
||||
int ebitmap_andnot(ebitmap_t *dst, const ebitmap_t *e1, const ebitmap_t *e2, unsigned int maxbit)
|
||||
{
|
||||
int rc;
|
||||
ebitmap_t e3;
|
||||
@ -126,10 +126,10 @@ int ebitmap_andnot(ebitmap_t *dst, ebitmap_t *e1, ebitmap_t *e2, unsigned int ma
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int ebitmap_cardinality(ebitmap_t *e1)
|
||||
unsigned int ebitmap_cardinality(const ebitmap_t *e1)
|
||||
{
|
||||
unsigned int count = 0;
|
||||
ebitmap_node_t *n;
|
||||
const ebitmap_node_t *n;
|
||||
|
||||
for (n = e1->node; n; n = n->next) {
|
||||
count += __builtin_popcountll(n->map);
|
||||
@ -137,7 +137,7 @@ unsigned int ebitmap_cardinality(ebitmap_t *e1)
|
||||
return count;
|
||||
}
|
||||
|
||||
int ebitmap_hamming_distance(ebitmap_t * e1, ebitmap_t * e2)
|
||||
int ebitmap_hamming_distance(const ebitmap_t * e1, const ebitmap_t * e2)
|
||||
{
|
||||
int rc;
|
||||
ebitmap_t tmp;
|
||||
@ -347,9 +347,9 @@ int ebitmap_set_bit(ebitmap_t * e, unsigned int bit, int value)
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int ebitmap_highest_set_bit(ebitmap_t * e)
|
||||
unsigned int ebitmap_highest_set_bit(const ebitmap_t * e)
|
||||
{
|
||||
ebitmap_node_t *n;
|
||||
const ebitmap_node_t *n;
|
||||
MAPTYPE map;
|
||||
unsigned int pos = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user