Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/sys PR/52826: Onno van der Linden: Return PRI_NONE ...



details:   https://anonhg.NetBSD.org/src/rev/ca28b6c684e1
branches:  trunk
changeset: 828499:ca28b6c684e1
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Dec 16 18:31:36 2017 +0000

description:
PR/52826: Onno van der Linden: Return PRI_NONE for sched_get_priority_m{in,ax}
and SCHED_OTHER.

diffstat:

 lib/libc/sys/sched.c |  22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r 981c411db223 -r ca28b6c684e1 lib/libc/sys/sched.c
--- a/lib/libc/sys/sched.c      Sat Dec 16 16:41:18 2017 +0000
+++ b/lib/libc/sys/sched.c      Sat Dec 16 18:31:36 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sched.c,v 1.4 2012/03/18 02:04:39 christos Exp $       */
+/*     $NetBSD: sched.c,v 1.5 2017/12/16 18:31:36 christos Exp $       */
 
 /*
  * Copyright (c) 2008, Mindaugas Rasiukevicius <rmind at NetBSD org>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: sched.c,v 1.4 2012/03/18 02:04:39 christos Exp $");
+__RCSID("$NetBSD: sched.c,v 1.5 2017/12/16 18:31:36 christos Exp $");
 
 #include <string.h>
 #include <unistd.h>
@@ -101,22 +101,32 @@
 sched_get_priority_max(int policy)
 {
 
-       if (policy < SCHED_OTHER || policy > SCHED_RR) {
+       switch (policy) {
+       case SCHED_OTHER:
+               return PRI_NONE;
+       case SCHED_RR:
+       case SCHED_FIFO:
+               return (int)sysconf(_SC_SCHED_PRI_MAX);
+       default:
                errno = EINVAL;
                return -1;
        }
-       return (int)sysconf(_SC_SCHED_PRI_MAX);
 }
 
 int
 sched_get_priority_min(int policy)
 {
 
-       if (policy < SCHED_OTHER || policy > SCHED_RR) {
+       switch (policy) {
+       case SCHED_OTHER:
+               return PRI_NONE;
+       case SCHED_RR:
+       case SCHED_FIFO:
+               return (int)sysconf(_SC_SCHED_PRI_MIN);
+       default:
                errno = EINVAL;
                return -1;
        }
-       return (int)sysconf(_SC_SCHED_PRI_MIN);
 }
 
 int



Home | Main Index | Thread Index | Old Index