diff options
author | dim <dim@FreeBSD.org> | 2014-11-01 13:45:01 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-01 13:45:01 +0000 |
commit | d8d62b896b89f951f88e70ff55e1b80172582d95 (patch) | |
tree | f53751d5f50077df48f42b3ec0e4bc4c1a564f73 /lib/libutil | |
parent | 4ca13eed64055e743be103902210019d21e7a458 (diff) | |
download | FreeBSD-src-d8d62b896b89f951f88e70ff55e1b80172582d95.zip FreeBSD-src-d8d62b896b89f951f88e70ff55e1b80172582d95.tar.gz |
MFC r273837:
Fix a clang 3.5 warning about abs(3) being given an argument of type
quad_t in setusercontext(). While here, sanitize the clamping of the
priority value, and use the correct type for the return value of
login_getcapnum().
Reviewed by: kib
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/login_class.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c index 263044f..8868005 100644 --- a/lib/libutil/login_class.c +++ b/lib/libutil/login_class.c @@ -423,7 +423,7 @@ setlogincontext(login_cap_t *lc, const struct passwd *pwd, int setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned int flags) { - quad_t p; + rlim_t p; mode_t mymask; login_cap_t *llc = NULL; struct sigaction sa, prevsa; @@ -448,16 +448,16 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in if (p > PRIO_MAX) { rtp.type = RTP_PRIO_IDLE; - rtp.prio = p - PRIO_MAX - 1; - p = (rtp.prio > RTP_PRIO_MAX) ? 31 : p; + p -= PRIO_MAX + 1; + rtp.prio = p > RTP_PRIO_MAX ? RTP_PRIO_MAX : p; if (rtprio(RTP_SET, 0, &rtp)) syslog(LOG_WARNING, "rtprio '%s' (%s): %m", pwd ? pwd->pw_name : "-", lc ? lc->lc_class : LOGIN_DEFCLASS); } else if (p < PRIO_MIN) { rtp.type = RTP_PRIO_REALTIME; - rtp.prio = abs(p - PRIO_MIN + RTP_PRIO_MAX); - p = (rtp.prio > RTP_PRIO_MAX) ? 1 : p; + p -= PRIO_MIN - RTP_PRIO_MAX; + rtp.prio = p < RTP_PRIO_MIN ? RTP_PRIO_MIN : p; if (rtprio(RTP_SET, 0, &rtp)) syslog(LOG_WARNING, "rtprio '%s' (%s): %m", pwd ? pwd->pw_name : "-", |