git: 9195f21e0f34 - stable/14 - MAC/do: parse_rule_element(): Style, more clarity
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 03 Apr 2025 19:32:15 UTC
The branch stable/14 has been updated by olce:
URL: https://cgit.FreeBSD.org/src/commit/?id=9195f21e0f34bc4132e4a4fc9229bf828b0e7164
commit 9195f21e0f34bc4132e4a4fc9229bf828b0e7164
Author: Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2024-07-04 16:35:47 +0000
Commit: Olivier Certner <olce@FreeBSD.org>
CommitDate: 2025-04-03 19:31:01 +0000
MAC/do: parse_rule_element(): Style, more clarity
Add newlines to separate logical blocks. Remove braces around 'if's
non-compound substatements.
No functional change (intended).
Reviewed by: bapt
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47611
(cherry picked from commit e4ce30f8da612db96410b66cccf9fc12ccce282a)
---
sys/security/mac_do/mac_do.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/sys/security/mac_do/mac_do.c b/sys/security/mac_do/mac_do.c
index ed1d0bcfa43c..4ef9b68bf513 100644
--- a/sys/security/mac_do/mac_do.c
+++ b/sys/security/mac_do/mac_do.c
@@ -94,19 +94,22 @@ parse_rule_element(char *element, struct rule **rule)
error = EINVAL;
goto error;
}
- if (strcmp(type, "uid") == 0) {
+
+ if (strcmp(type, "uid") == 0)
new->from_type = RULE_UID;
- } else if (strcmp(type, "gid") == 0) {
+ else if (strcmp(type, "gid") == 0)
new->from_type = RULE_GID;
- } else {
+ else {
error = EINVAL;
goto error;
}
+
id = strsep(&element, ":");
if (id == NULL) {
error = EINVAL;
goto error;
}
+
switch (new->from_type) {
case RULE_UID:
new->f_uid = strtol(id, &p, 10);
@@ -121,13 +124,14 @@ parse_rule_element(char *element, struct rule **rule)
error = EINVAL;
goto error;
}
+
if (element == NULL || *element == '\0') {
error = EINVAL;
goto error;
}
- if (strcmp(element, "any") == 0 || strcmp(element, "*") == 0) {
+ if (strcmp(element, "any") == 0 || strcmp(element, "*") == 0)
new->to_type = RULE_ANY;
- } else {
+ else {
new->to_type = RULE_UID;
new->t_uid = strtol(element, &p, 10);
if (*p != '\0') {