From f1dadd190226a809452e3de41331807968e1e0bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Mon, 29 Apr 2024 18:31:21 +0200 Subject: [PATCH] libselinux: constify selinux_set_mapping(3) parameter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: James Carter --- libselinux/include/selinux/selinux.h | 2 +- libselinux/man/man3/selinux_set_mapping.3 | 2 +- libselinux/src/mapping.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libselinux/include/selinux/selinux.h b/libselinux/include/selinux/selinux.h index 83ea871ccf..61c1422b8a 100644 --- a/libselinux/include/selinux/selinux.h +++ b/libselinux/include/selinux/selinux.h @@ -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 */ diff --git a/libselinux/man/man3/selinux_set_mapping.3 b/libselinux/man/man3/selinux_set_mapping.3 index a1f82e5a63..bb48eb4317 100644 --- a/libselinux/man/man3/selinux_set_mapping.3 +++ b/libselinux/man/man3/selinux_set_mapping.3 @@ -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 () diff --git a/libselinux/src/mapping.c b/libselinux/src/mapping.c index dd2f10390a..d863e44941 100644 --- a/libselinux/src/mapping.c +++ b/libselinux/src/mapping.c @@ -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; @@ -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);