On Tue, Jun 8, 2021 at 12:01 PM Christian Göttsche <cgzones@xxxxxxxxxxxxxx> wrote: > > 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@xxxxxxxxxxxxxx> Acked-by: James Carter <jwcart2@xxxxxxxxx> > --- > libsepol/include/sepol/policydb/ebitmap.h | 16 ++++++++-------- > libsepol/src/ebitmap.c | 18 +++++++++--------- > 2 files changed, 17 insertions(+), 17 deletions(-) > > diff --git a/libsepol/include/sepol/policydb/ebitmap.h b/libsepol/include/sepol/policydb/ebitmap.h > index 634436f6..81d0c7a6 100644 > --- a/libsepol/include/sepol/policydb/ebitmap.h > +++ b/libsepol/include/sepol/policydb/ebitmap.h > @@ -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); > > diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c > index 522e14a6..4e9acdf8 100644 > --- a/libsepol/src/ebitmap.c > +++ b/libsepol/src/ebitmap.c > @@ -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; > > -- > 2.32.0 >