The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=4e27cc086b3f9e029160da8830abacb06a2f9e39
commit 4e27cc086b3f9e029160da8830abacb06a2f9e39 Author: Olivier Certner <[email protected]> AuthorDate: 2026-05-20 09:38:37 +0000 Commit: Olivier Certner <[email protected]> CommitDate: 2026-05-29 15:22:43 +0000 MAC/do: Move static assertions on constants close to their definitions And document more clearly their purpose. Reviewed by: bapt MFC after: 1 month Sponsored by: The FreeBSD Foundation Pull Request: https://ron-dev.freebsd.org/FreeBSD/src/pulls/38 --- sys/security/mac_do/mac_do.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c index 7a08cdd5425f..1d9b756bc0fc 100644 --- a/sys/security/mac_do/mac_do.c +++ b/sys/security/mac_do/mac_do.c @@ -47,10 +47,14 @@ SYSCTL_INT(_security_mac_do, OID_AUTO, print_parse_error, CTLFLAG_RWTUN, static MALLOC_DEFINE(M_MAC_DO, "mac_do", "mac_do(4) security module"); +#define MAX_RULE_STRING_SIZE 1024 +_Static_assert(MAX_RULE_STRING_SIZE > 0, + "MAX_RULE_STRING_SIZE: No space for the NUL terminator!"); + #define MAX_EXEC_PATHS_SIZE 2048 #define MAX_EXEC_PATHS 8 - -#define MAX_RULE_STRING_SIZE 1024 +_Static_assert(MAX_EXEC_PATHS_SIZE > 0, + "MAX_EXEC_PATHS_SIZE: No space for the NUL terminator!"); static unsigned osd_jail_slot; static unsigned osd_thread_slot; @@ -353,14 +357,12 @@ toast_rules(struct rules *const rules) static void init_rules(struct rules *const rules) { - _Static_assert(MAX_RULE_STRING_SIZE > 0, "MAX_RULE_STRING_SIZE <= 0!"); STAILQ_INIT(&rules->head); } static void init_exec_paths(struct exec_paths *const exec_paths) { - _Static_assert(MAX_EXEC_PATHS_SIZE > 0, "MAX_EXEC_PATHS_SIZE <= 0!"); bzero(exec_paths, sizeof(*exec_paths)); exec_paths->exec_paths_str[0] = 0; }
