diff mbox series

[1/9] libsepol: ebitmap: mark nodes of const ebitmaps const

Message ID 20210928154620.11181-1-cgzones@googlemail.com (mailing list archive)
State Accepted
Headers show
Series [1/9] libsepol: ebitmap: mark nodes of const ebitmaps const | expand

Commit Message

Christian Göttsche Sept. 28, 2021, 3:46 p.m. UTC
Mark pointers to nodes of const ebitmaps also const. C does not enforce
a transitive const-ness, but it clarifies the intent and improves
maintainability.

Follow-up of 390ec54d278a

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/ebitmap.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

James Carter Sept. 30, 2021, 7:40 p.m. UTC | #1
On Tue, Sep 28, 2021 at 11:47 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Mark pointers to nodes of const ebitmaps also const. C does not enforce
> a transitive const-ness, but it clarifies the intent and improves
> maintainability.
>
> Follow-up of 390ec54d278a
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

For all 9 patches:
Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/src/ebitmap.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c
> index 4e9acdf8..1de3816a 100644
> --- a/libsepol/src/ebitmap.c
> +++ b/libsepol/src/ebitmap.c
> @@ -17,7 +17,8 @@
>
>  int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2)
>  {
> -       ebitmap_node_t *n1, *n2, *new, *prev;
> +       const ebitmap_node_t *n1, *n2;
> +       ebitmap_node_t *new, *prev;
>
>         ebitmap_init(dst);
>
> @@ -154,7 +155,7 @@ int ebitmap_hamming_distance(const ebitmap_t * e1, const ebitmap_t * e2)
>
>  int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2)
>  {
> -       ebitmap_node_t *n1, *n2;
> +       const ebitmap_node_t *n1, *n2;
>
>         if (e1->highbit != e2->highbit)
>                 return 0;
> @@ -175,7 +176,8 @@ int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2)
>
>  int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
>  {
> -       ebitmap_node_t *n, *new, *prev;
> +       const ebitmap_node_t *n;
> +       ebitmap_node_t *new, *prev;
>
>         ebitmap_init(dst);
>         n = src->node;
> @@ -204,7 +206,7 @@ int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
>
>  int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
>  {
> -       ebitmap_node_t *n1, *n2;
> +       const ebitmap_node_t *n1, *n2;
>
>         if (e1->highbit < e2->highbit)
>                 return 0;
> @@ -231,8 +233,8 @@ int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
>
>  int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
>  {
> -       ebitmap_node_t *n1 = e1->node;
> -       ebitmap_node_t *n2 = e2->node;
> +       const ebitmap_node_t *n1 = e1->node;
> +       const ebitmap_node_t *n2 = e2->node;
>
>         while (n1 && n2) {
>                 if (n1->startbit < n2->startbit) {
> @@ -253,7 +255,7 @@ int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
>
>  int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit)
>  {
> -       ebitmap_node_t *n;
> +       const ebitmap_node_t *n;
>
>         if (e->highbit < bit)
>                 return 0;
> --
> 2.33.0
>
James Carter Oct. 4, 2021, 1:36 p.m. UTC | #2
On Thu, Sep 30, 2021 at 3:40 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Tue, Sep 28, 2021 at 11:47 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > Mark pointers to nodes of const ebitmaps also const. C does not enforce
> > a transitive const-ness, but it clarifies the intent and improves
> > maintainability.
> >
> > Follow-up of 390ec54d278a
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> For all 9 patches:
> Acked-by: James Carter <jwcart2@gmail.com>
>

All nine patches have been merged.
Thanks,
Jim

> > ---
> >  libsepol/src/ebitmap.c | 16 +++++++++-------
> >  1 file changed, 9 insertions(+), 7 deletions(-)
> >
> > diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c
> > index 4e9acdf8..1de3816a 100644
> > --- a/libsepol/src/ebitmap.c
> > +++ b/libsepol/src/ebitmap.c
> > @@ -17,7 +17,8 @@
> >
> >  int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2)
> >  {
> > -       ebitmap_node_t *n1, *n2, *new, *prev;
> > +       const ebitmap_node_t *n1, *n2;
> > +       ebitmap_node_t *new, *prev;
> >
> >         ebitmap_init(dst);
> >
> > @@ -154,7 +155,7 @@ int ebitmap_hamming_distance(const ebitmap_t * e1, const ebitmap_t * e2)
> >
> >  int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2)
> >  {
> > -       ebitmap_node_t *n1, *n2;
> > +       const ebitmap_node_t *n1, *n2;
> >
> >         if (e1->highbit != e2->highbit)
> >                 return 0;
> > @@ -175,7 +176,8 @@ int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2)
> >
> >  int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
> >  {
> > -       ebitmap_node_t *n, *new, *prev;
> > +       const ebitmap_node_t *n;
> > +       ebitmap_node_t *new, *prev;
> >
> >         ebitmap_init(dst);
> >         n = src->node;
> > @@ -204,7 +206,7 @@ int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
> >
> >  int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
> >  {
> > -       ebitmap_node_t *n1, *n2;
> > +       const ebitmap_node_t *n1, *n2;
> >
> >         if (e1->highbit < e2->highbit)
> >                 return 0;
> > @@ -231,8 +233,8 @@ int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
> >
> >  int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
> >  {
> > -       ebitmap_node_t *n1 = e1->node;
> > -       ebitmap_node_t *n2 = e2->node;
> > +       const ebitmap_node_t *n1 = e1->node;
> > +       const ebitmap_node_t *n2 = e2->node;
> >
> >         while (n1 && n2) {
> >                 if (n1->startbit < n2->startbit) {
> > @@ -253,7 +255,7 @@ int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
> >
> >  int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit)
> >  {
> > -       ebitmap_node_t *n;
> > +       const ebitmap_node_t *n;
> >
> >         if (e->highbit < bit)
> >                 return 0;
> > --
> > 2.33.0
> >
diff mbox series

Patch

diff --git a/libsepol/src/ebitmap.c b/libsepol/src/ebitmap.c
index 4e9acdf8..1de3816a 100644
--- a/libsepol/src/ebitmap.c
+++ b/libsepol/src/ebitmap.c
@@ -17,7 +17,8 @@ 
 
 int ebitmap_or(ebitmap_t * dst, const ebitmap_t * e1, const ebitmap_t * e2)
 {
-	ebitmap_node_t *n1, *n2, *new, *prev;
+	const ebitmap_node_t *n1, *n2;
+	ebitmap_node_t *new, *prev;
 
 	ebitmap_init(dst);
 
@@ -154,7 +155,7 @@  int ebitmap_hamming_distance(const ebitmap_t * e1, const ebitmap_t * e2)
 
 int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2)
 {
-	ebitmap_node_t *n1, *n2;
+	const ebitmap_node_t *n1, *n2;
 
 	if (e1->highbit != e2->highbit)
 		return 0;
@@ -175,7 +176,8 @@  int ebitmap_cmp(const ebitmap_t * e1, const ebitmap_t * e2)
 
 int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
 {
-	ebitmap_node_t *n, *new, *prev;
+	const ebitmap_node_t *n;
+	ebitmap_node_t *new, *prev;
 
 	ebitmap_init(dst);
 	n = src->node;
@@ -204,7 +206,7 @@  int ebitmap_cpy(ebitmap_t * dst, const ebitmap_t * src)
 
 int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
 {
-	ebitmap_node_t *n1, *n2;
+	const ebitmap_node_t *n1, *n2;
 
 	if (e1->highbit < e2->highbit)
 		return 0;
@@ -231,8 +233,8 @@  int ebitmap_contains(const ebitmap_t * e1, const ebitmap_t * e2)
 
 int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
 {
-	ebitmap_node_t *n1 = e1->node;
-	ebitmap_node_t *n2 = e2->node;
+	const ebitmap_node_t *n1 = e1->node;
+	const ebitmap_node_t *n2 = e2->node;
 
 	while (n1 && n2) {
 		if (n1->startbit < n2->startbit) {
@@ -253,7 +255,7 @@  int ebitmap_match_any(const ebitmap_t *e1, const ebitmap_t *e2)
 
 int ebitmap_get_bit(const ebitmap_t * e, unsigned int bit)
 {
-	ebitmap_node_t *n;
+	const ebitmap_node_t *n;
 
 	if (e->highbit < bit)
 		return 0;