From nobody Mon Dec 16 14:46:00 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YBjRr4nknz5hWZ7; Mon, 16 Dec 2024 14:46:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YBjRr1nnKz4dlK; Mon, 16 Dec 2024 14:46:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kMkzboLw6YPOJZAK3iqnX0IgHjSbFIr4tde5Hp040Ro=; b=DO9wTar7qcWdBSms2PLDX8Ya07K2brUOs7s57dVlZcUOvAQH/ggEx+6gfNVPuu8zcL04pf WDyiEvp7Q52jToERhfWHhLIqeNI0xKXwZ0nG4uxgB7D18NSBhSvSfWzKAw2jaA3TrV+uNI gwna7yCAGbfZczusSatHD6UEqcnP+jQokdbDQDXa7p6CAe+stnG3p2knE+wQ/UPMbXy4Oq 1CsAkSuYfek1BZKNoYiCBI78zWVE7zuSDjcgGNpmAxLyD/siP174TvfHvyrEjUm3WM3EaC YACrs8JSuvXKs6RV/bk8dJPbSKtEfXmqtbB7SM+V5PhVb/o6acg8FCE1zG6AVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734360360; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kMkzboLw6YPOJZAK3iqnX0IgHjSbFIr4tde5Hp040Ro=; b=pZOAcVKqKFtRSKt6pnRiiY4HHx5gDhusVVNlVMJ3AyD5CwlZVq+uD1vS0rSFDc7EJqaj1T pG9mCXzuXCn49o7vomXUG4NyMX7DiFrlLddsIK9AIznj9WL49oHr88+TzlGFfvhAT7267j Tapu4qmbTjwPIUThtPHTu70uS1EDw/oA/Ztk9PQKe84lRYysD1LjhZNeT0zpAfFsniw1hr jrF5UxyMuEkpVv0fKKJm9Utf4FeNBPeH0+/eHkcvVgEiASBrE61SPZULFls58ALW3hPyGX k7JokU6tSniO2nQjhQwt5t58Dhr1+oD07dNS5SI5U/Xj40qNNVRQmfRkzwY2fA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734360360; a=rsa-sha256; cv=none; b=CTdnBkb+q+i2C/LIKaZ00GMIFUoitedqa/epcAGYMf8oprz2fxG439V+XieLBbdu22Wk3P AUgocV8M+yJFZJmLwQQ2iCEFKzNpGJ+TqUxqupOL/0hsxtczd7kO4OncXYc7IY/z215CHC IKmzymDGlBdftka2/YxNqze8T505MoKTg3w69fIWp3YymI7Aj1HWl14jXKeAAZhNgmaaGJ 9T9ljkxa0KK/1woyR7dH+8RI65J+bLqZ/p1IoRrSp2jYVS7blsHxM21fFg0QkNYzMGpvKQ VeVud3SbVO8flM5zcxLYVI4mwfJ6VFZNNm1rctaPYiFOcY5o53RQLU2h9j/fgw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YBjRr1NbCzxH9; Mon, 16 Dec 2024 14:46:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BGEk0im053507; Mon, 16 Dec 2024 14:46:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BGEk0dP053504; Mon, 16 Dec 2024 14:46:00 GMT (envelope-from git) Date: Mon, 16 Dec 2024 14:46:00 GMT Message-Id: <202412161446.4BGEk0dP053504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: e4ce30f8da61 - main - MAC/do: parse_rule_element(): Style, more clarity List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e4ce30f8da612db96410b66cccf9fc12ccce282a Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=e4ce30f8da612db96410b66cccf9fc12ccce282a commit e4ce30f8da612db96410b66cccf9fc12ccce282a Author: Olivier Certner AuthorDate: 2024-07-04 16:35:47 +0000 Commit: Olivier Certner CommitDate: 2024-12-16 14:42:37 +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 --- 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') {