libselinux: constify selinux_set_mapping(3) parameter

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 <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Christian Göttsche 2024-04-29 18:31:21 +02:00 committed by James Carter
parent d370cbfc85
commit f1dadd1902
3 changed files with 4 additions and 4 deletions

View File

@ -413,7 +413,7 @@ struct security_class_mapping {
* starting at 1, and have one security_class_mapping structure entry * starting at 1, and have one security_class_mapping structure entry
* per define. * 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 */ /* Common helpers */

View File

@ -15,7 +15,7 @@ struct security_class_mapping {
}; };
.fi .fi
.sp .sp
.BI "int selinux_set_mapping(struct security_class_mapping *" map ");" .BI "int selinux_set_mapping(const struct security_class_mapping *" map ");"
. .
.SH "DESCRIPTION" .SH "DESCRIPTION"
.BR selinux_set_mapping () .BR selinux_set_mapping ()

View File

@ -31,7 +31,7 @@ static security_class_t current_mapping_size = 0;
*/ */
int 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); size_t size = sizeof(struct selinux_mapping);
security_class_t i, j; security_class_t i, j;
@ -64,7 +64,7 @@ selinux_set_mapping(struct security_class_mapping *map)
/* Store the raw class and permission values */ /* Store the raw class and permission values */
j = 0; j = 0;
while (map[j].name) { 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; struct selinux_mapping *p_out = current_mapping + j;
p_out->value = string_to_security_class(p_in->name); p_out->value = string_to_security_class(p_in->name);