Skip to content

Commit

Permalink
libselinux: constify selinux_set_mapping(3) parameter
Browse files Browse the repository at this point in the history
The map parameter of selinux_set_mapping(3) is only read from and not
modified, thus declare it const.

Signed-off-by: Christian Göttsche <[email protected]>
Acked-by: James Carter <[email protected]>
  • Loading branch information
cgzones authored and jwcart2 committed May 1, 2024
1 parent d370cbf commit f1dadd1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libselinux/include/selinux/selinux.h
Expand Up @@ -413,7 +413,7 @@ struct security_class_mapping {
* starting at 1, and have one security_class_mapping structure entry
* per define.
*/
extern int selinux_set_mapping(struct security_class_mapping *map);
extern int selinux_set_mapping(const struct security_class_mapping *map);

/* Common helpers */

Expand Down
2 changes: 1 addition & 1 deletion libselinux/man/man3/selinux_set_mapping.3
Expand Up @@ -15,7 +15,7 @@ struct security_class_mapping {
};
.fi
.sp
.BI "int selinux_set_mapping(struct security_class_mapping *" map ");"
.BI "int selinux_set_mapping(const struct security_class_mapping *" map ");"
.
.SH "DESCRIPTION"
.BR selinux_set_mapping ()
Expand Down
4 changes: 2 additions & 2 deletions libselinux/src/mapping.c
Expand Up @@ -31,7 +31,7 @@ static security_class_t current_mapping_size = 0;
*/

int
selinux_set_mapping(struct security_class_mapping *map)
selinux_set_mapping(const struct security_class_mapping *map)
{
size_t size = sizeof(struct selinux_mapping);
security_class_t i, j;
Expand Down Expand Up @@ -64,7 +64,7 @@ selinux_set_mapping(struct security_class_mapping *map)
/* Store the raw class and permission values */
j = 0;
while (map[j].name) {
struct security_class_mapping *p_in = map + (j++);
const struct security_class_mapping *p_in = map + (j++);
struct selinux_mapping *p_out = current_mapping + j;

p_out->value = string_to_security_class(p_in->name);
Expand Down

0 comments on commit f1dadd1

Please sign in to comment.