git: 83ac32d9a0f8 - stable/14 - setlogincontext(): Comply to style(9)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 01 Feb 2024 21:31:13 UTC
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=83ac32d9a0f81ccf89f708d159e6d060b53d5a32 commit 83ac32d9a0f81ccf89f708d159e6d060b53d5a32 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2023-05-25 14:29:22 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2024-02-01 21:29:17 +0000 setlogincontext(): Comply to style(9) Remove indentation by inverting the big 'if (lc)' and using 'return'. Use explicit binary operators to produce booleans. Reviewed by: emaste, kib, dchagin Approved by: emaste (mentor) MFC after: 3 days Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40346 (cherry picked from commit 771d5c93ab5a3fb1701d9706df2ce87d6a9da6f3) Approved by: markj (mentor) --- lib/libutil/login_class.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index e6485afade43..33a2189277ca 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -431,23 +431,28 @@ setclassumask(login_cap_t *lc, const struct passwd *pwd) static void setlogincontext(login_cap_t *lc, const struct passwd *pwd, unsigned long flags) { - if (lc) { - /* Set resources */ - if (flags & LOGIN_SETRESOURCES) - setclassresources(lc); - /* See if there's a umask override */ - if (flags & LOGIN_SETUMASK) - setclassumask(lc, pwd); - /* Set paths */ - if (flags & LOGIN_SETPATH) - setclassenvironment(lc, pwd, 1); - /* Set environment */ - if (flags & LOGIN_SETENV) - setclassenvironment(lc, pwd, 0); - /* Set cpu affinity */ - if (flags & LOGIN_SETCPUMASK) - setclasscpumask(lc); - } + if (lc == NULL) + return; + + /* Set resources. */ + if ((flags & LOGIN_SETRESOURCES) != 0) + setclassresources(lc); + + /* See if there's a umask override. */ + if ((flags & LOGIN_SETUMASK) != 0) + setclassumask(lc, pwd); + + /* Set paths. */ + if ((flags & LOGIN_SETPATH) != 0) + setclassenvironment(lc, pwd, 1); + + /* Set environment. */ + if ((flags & LOGIN_SETENV) != 0) + setclassenvironment(lc, pwd, 0); + + /* Set cpu affinity. */ + if ((flags & LOGIN_SETCPUMASK) != 0) + setclasscpumask(lc); }