Skip to content

Commit

Permalink
libsepol: contify function pointer arrays
Browse files Browse the repository at this point in the history
These function pointers are never modified.

Signed-off-by: Christian Göttsche <[email protected]>
Acked-by: James Carter <[email protected]>
  • Loading branch information
cgzones authored and jwcart2 committed Jun 14, 2024
1 parent a02fccf commit c9ed9ea
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions libsepol/src/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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};
Expand Down
8 changes: 4 additions & 4 deletions libsepol/src/module_to_cil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -3404,7 +3404,7 @@ static int file_contexts_to_cil(struct sepol_module_package *mod_pkg)
}


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,
Expand Down
2 changes: 1 addition & 1 deletion libsepol/src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,};
Expand Down

0 comments on commit c9ed9ea

Please sign in to comment.