diff mbox series

libsepol: contify function pointer arrays

Message ID 20240608171739.135501-1-cgoettsche@seltendoof.de (mailing list archive)
State Accepted
Commit c9ed9ea63d7a
Delegated to: Petr Lautrbach
Headers show
Series libsepol: contify function pointer arrays | expand

Commit Message

Christian Göttsche June 8, 2024, 5:17 p.m. UTC
From: Christian Göttsche <cgzones@googlemail.com>

These function pointers are never modified.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libsepol/src/link.c          | 4 ++--
 libsepol/src/module_to_cil.c | 8 ++++----
 libsepol/src/write.c         | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

Comments

James Carter June 12, 2024, 6:41 p.m. UTC | #1
On Sat, Jun 8, 2024 at 1:27 PM Christian Göttsche
<cgoettsche@seltendoof.de> wrote:
>
> From: Christian Göttsche <cgzones@googlemail.com>
>
> These function pointers are never modified.
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/src/link.c          | 4 ++--
>  libsepol/src/module_to_cil.c | 8 ++++----
>  libsepol/src/write.c         | 2 +-
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/libsepol/src/link.c b/libsepol/src/link.c
> index b8272308..048d742e 100644
> --- a/libsepol/src/link.c
> +++ b/libsepol/src/link.c
> @@ -749,7 +749,7 @@ static int cat_copy_callback(hashtab_key_t key, hashtab_datum_t datum,
>         return 0;
>  }
>
> -static int (*copy_callback_f[SYM_NUM]) (hashtab_key_t key,
> +static int (*const copy_callback_f[SYM_NUM]) (hashtab_key_t key,
>                                         hashtab_datum_t datum, void *datap) = {
>  NULL, class_copy_callback, role_copy_callback, type_copy_callback,
>             user_copy_callback, bool_copy_callback, sens_copy_callback,
> @@ -1215,7 +1215,7 @@ static int user_fix_callback(hashtab_key_t key, hashtab_datum_t datum,
>         return -1;
>  }
>
> -static int (*fix_callback_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
> +static int (*const fix_callback_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
>                                        void *datap) = {
>  NULL, NULL, role_fix_callback, type_fix_callback, user_fix_callback,
>             NULL, NULL, NULL};
> diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
> index 3b3480bf..2dbf137e 100644
> --- a/libsepol/src/module_to_cil.c
> +++ b/libsepol/src/module_to_cil.c
> @@ -2951,8 +2951,8 @@ static int ocontexts_to_cil(struct policydb *pdb)
>         int rc = -1;
>         int ocon;
>
> -       static int (**ocon_funcs)(struct policydb *pdb, struct ocontext *ocon);
> -       static int (*ocon_selinux_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
> +       static int (*const *ocon_funcs)(struct policydb *pdb, struct ocontext *ocon);
> +       static int (*const ocon_selinux_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
>                 ocontext_selinux_isid_to_cil,
>                 ocontext_selinux_fs_to_cil,
>                 ocontext_selinux_port_to_cil,
> @@ -2963,7 +2963,7 @@ static int ocontexts_to_cil(struct policydb *pdb)
>                 ocontext_selinux_ibpkey_to_cil,
>                 ocontext_selinux_ibendport_to_cil,
>         };
> -       static int (*ocon_xen_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
> +       static int (*const ocon_xen_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
>                 ocontext_xen_isid_to_cil,
>                 ocontext_xen_pirq_to_cil,
>                 ocontext_xen_ioport_to_cil,
> @@ -3404,7 +3404,7 @@ exit:
>  }
>
>
> -static int (*func_to_cil[SYM_NUM])(int indent, struct policydb *pdb, struct avrule_block *block, struct stack *decl_stack, char *key, void *datum, int scope) = {
> +static int (*const func_to_cil[SYM_NUM])(int indent, struct policydb *pdb, struct avrule_block *block, struct stack *decl_stack, char *key, void *datum, int scope) = {
>         NULL,   // commons, only stored in the global symtab, handled elsewhere
>         class_to_cil,
>         role_to_cil,
> diff --git a/libsepol/src/write.c b/libsepol/src/write.c
> index f8cd9e1d..a52e2e82 100644
> --- a/libsepol/src/write.c
> +++ b/libsepol/src/write.c
> @@ -1344,7 +1344,7 @@ static int user_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
>         return POLICYDB_SUCCESS;
>  }
>
> -static int (*write_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
> +static int (*const write_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
>                                 void *datap) = {
>  common_write, class_write, role_write, type_write, user_write,
>             cond_write_bool, sens_write, cat_write,};
> --
> 2.45.1
>
>
James Carter June 14, 2024, 2:13 p.m. UTC | #2
On Wed, Jun 12, 2024 at 2:41 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Sat, Jun 8, 2024 at 1:27 PM Christian Göttsche
> <cgoettsche@seltendoof.de> wrote:
> >
> > From: Christian Göttsche <cgzones@googlemail.com>
> >
> > These function pointers are never modified.
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>

Merged.
Thanks,
Jim

> > ---
> >  libsepol/src/link.c          | 4 ++--
> >  libsepol/src/module_to_cil.c | 8 ++++----
> >  libsepol/src/write.c         | 2 +-
> >  3 files changed, 7 insertions(+), 7 deletions(-)
> >
> > diff --git a/libsepol/src/link.c b/libsepol/src/link.c
> > index b8272308..048d742e 100644
> > --- a/libsepol/src/link.c
> > +++ b/libsepol/src/link.c
> > @@ -749,7 +749,7 @@ static int cat_copy_callback(hashtab_key_t key, hashtab_datum_t datum,
> >         return 0;
> >  }
> >
> > -static int (*copy_callback_f[SYM_NUM]) (hashtab_key_t key,
> > +static int (*const copy_callback_f[SYM_NUM]) (hashtab_key_t key,
> >                                         hashtab_datum_t datum, void *datap) = {
> >  NULL, class_copy_callback, role_copy_callback, type_copy_callback,
> >             user_copy_callback, bool_copy_callback, sens_copy_callback,
> > @@ -1215,7 +1215,7 @@ static int user_fix_callback(hashtab_key_t key, hashtab_datum_t datum,
> >         return -1;
> >  }
> >
> > -static int (*fix_callback_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
> > +static int (*const fix_callback_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
> >                                        void *datap) = {
> >  NULL, NULL, role_fix_callback, type_fix_callback, user_fix_callback,
> >             NULL, NULL, NULL};
> > diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
> > index 3b3480bf..2dbf137e 100644
> > --- a/libsepol/src/module_to_cil.c
> > +++ b/libsepol/src/module_to_cil.c
> > @@ -2951,8 +2951,8 @@ static int ocontexts_to_cil(struct policydb *pdb)
> >         int rc = -1;
> >         int ocon;
> >
> > -       static int (**ocon_funcs)(struct policydb *pdb, struct ocontext *ocon);
> > -       static int (*ocon_selinux_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
> > +       static int (*const *ocon_funcs)(struct policydb *pdb, struct ocontext *ocon);
> > +       static int (*const ocon_selinux_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
> >                 ocontext_selinux_isid_to_cil,
> >                 ocontext_selinux_fs_to_cil,
> >                 ocontext_selinux_port_to_cil,
> > @@ -2963,7 +2963,7 @@ static int ocontexts_to_cil(struct policydb *pdb)
> >                 ocontext_selinux_ibpkey_to_cil,
> >                 ocontext_selinux_ibendport_to_cil,
> >         };
> > -       static int (*ocon_xen_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
> > +       static int (*const ocon_xen_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
> >                 ocontext_xen_isid_to_cil,
> >                 ocontext_xen_pirq_to_cil,
> >                 ocontext_xen_ioport_to_cil,
> > @@ -3404,7 +3404,7 @@ exit:
> >  }
> >
> >
> > -static int (*func_to_cil[SYM_NUM])(int indent, struct policydb *pdb, struct avrule_block *block, struct stack *decl_stack, char *key, void *datum, int scope) = {
> > +static int (*const func_to_cil[SYM_NUM])(int indent, struct policydb *pdb, struct avrule_block *block, struct stack *decl_stack, char *key, void *datum, int scope) = {
> >         NULL,   // commons, only stored in the global symtab, handled elsewhere
> >         class_to_cil,
> >         role_to_cil,
> > diff --git a/libsepol/src/write.c b/libsepol/src/write.c
> > index f8cd9e1d..a52e2e82 100644
> > --- a/libsepol/src/write.c
> > +++ b/libsepol/src/write.c
> > @@ -1344,7 +1344,7 @@ static int user_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
> >         return POLICYDB_SUCCESS;
> >  }
> >
> > -static int (*write_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
> > +static int (*const write_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
> >                                 void *datap) = {
> >  common_write, class_write, role_write, type_write, user_write,
> >             cond_write_bool, sens_write, cat_write,};
> > --
> > 2.45.1
> >
> >
diff mbox series

Patch

diff --git a/libsepol/src/link.c b/libsepol/src/link.c
index b8272308..048d742e 100644
--- a/libsepol/src/link.c
+++ b/libsepol/src/link.c
@@ -749,7 +749,7 @@  static int cat_copy_callback(hashtab_key_t key, hashtab_datum_t datum,
 	return 0;
 }
 
-static int (*copy_callback_f[SYM_NUM]) (hashtab_key_t key,
+static int (*const copy_callback_f[SYM_NUM]) (hashtab_key_t key,
 					hashtab_datum_t datum, void *datap) = {
 NULL, class_copy_callback, role_copy_callback, type_copy_callback,
 	    user_copy_callback, bool_copy_callback, sens_copy_callback,
@@ -1215,7 +1215,7 @@  static int user_fix_callback(hashtab_key_t key, hashtab_datum_t datum,
 	return -1;
 }
 
-static int (*fix_callback_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
+static int (*const fix_callback_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
 				       void *datap) = {
 NULL, NULL, role_fix_callback, type_fix_callback, user_fix_callback,
 	    NULL, NULL, NULL};
diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c
index 3b3480bf..2dbf137e 100644
--- a/libsepol/src/module_to_cil.c
+++ b/libsepol/src/module_to_cil.c
@@ -2951,8 +2951,8 @@  static int ocontexts_to_cil(struct policydb *pdb)
 	int rc = -1;
 	int ocon;
 
-	static int (**ocon_funcs)(struct policydb *pdb, struct ocontext *ocon);
-	static int (*ocon_selinux_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
+	static int (*const *ocon_funcs)(struct policydb *pdb, struct ocontext *ocon);
+	static int (*const ocon_selinux_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
 		ocontext_selinux_isid_to_cil,
 		ocontext_selinux_fs_to_cil,
 		ocontext_selinux_port_to_cil,
@@ -2963,7 +2963,7 @@  static int ocontexts_to_cil(struct policydb *pdb)
 		ocontext_selinux_ibpkey_to_cil,
 		ocontext_selinux_ibendport_to_cil,
 	};
-	static int (*ocon_xen_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
+	static int (*const ocon_xen_funcs[OCON_NUM])(struct policydb *pdb, struct ocontext *ocon) = {
 		ocontext_xen_isid_to_cil,
 		ocontext_xen_pirq_to_cil,
 		ocontext_xen_ioport_to_cil,
@@ -3404,7 +3404,7 @@  exit:
 }
 
 
-static int (*func_to_cil[SYM_NUM])(int indent, struct policydb *pdb, struct avrule_block *block, struct stack *decl_stack, char *key, void *datum, int scope) = {
+static int (*const func_to_cil[SYM_NUM])(int indent, struct policydb *pdb, struct avrule_block *block, struct stack *decl_stack, char *key, void *datum, int scope) = {
 	NULL,	// commons, only stored in the global symtab, handled elsewhere
 	class_to_cil,
 	role_to_cil,
diff --git a/libsepol/src/write.c b/libsepol/src/write.c
index f8cd9e1d..a52e2e82 100644
--- a/libsepol/src/write.c
+++ b/libsepol/src/write.c
@@ -1344,7 +1344,7 @@  static int user_write(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
 	return POLICYDB_SUCCESS;
 }
 
-static int (*write_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
+static int (*const write_f[SYM_NUM]) (hashtab_key_t key, hashtab_datum_t datum,
 				void *datap) = {
 common_write, class_write, role_write, type_write, user_write,
 	    cond_write_bool, sens_write, cat_write,};