Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/compat/freebsd Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/f28da89125a3
branches:  netbsd-6
changeset: 776656:f28da89125a3
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Jun 26 04:00:30 2014 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #1086):
        sys/compat/freebsd/freebsd_sched.c      1.20-1.21

Avoid NULL dereference and fix sched param conversion (at least make it
do something). Pointed out by Maxime Villard.

Simplify and clarify.

diffstat:

 sys/compat/freebsd/freebsd_sched.c |  60 +++++++++++++++++++-------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diffs (127 lines):

diff -r c8de953aadc2 -r f28da89125a3 sys/compat/freebsd/freebsd_sched.c
--- a/sys/compat/freebsd/freebsd_sched.c        Thu Jun 26 03:28:47 2014 +0000
+++ b/sys/compat/freebsd/freebsd_sched.c        Thu Jun 26 04:00:30 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: freebsd_sched.c,v 1.19 2008/04/28 20:23:41 martin Exp $        */
+/*     $NetBSD: freebsd_sched.c,v 1.19.40.1 2014/06/26 04:00:30 msaitoh Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: freebsd_sched.c,v 1.19 2008/04/28 20:23:41 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: freebsd_sched.c,v 1.19.40.1 2014/06/26 04:00:30 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/mount.h>
@@ -62,72 +62,72 @@
  */
 static int
 sched_freebsd2native(int freebsd_policy,
-    struct freebsd_sched_param *freebsd_params, int *native_policy,
+    const struct freebsd_sched_param *freebsd_params, int *native_policy,
     struct sched_param *native_params)
 {
-       int error;
-
-       error = 0;
+       int p;
 
        switch (freebsd_policy) {
        case FREEBSD_SCHED_OTHER:
-               *native_policy = SCHED_OTHER;
+               p = SCHED_OTHER;
                break;
 
        case FREEBSD_SCHED_FIFO:
-               *native_policy = SCHED_FIFO;
+               p = SCHED_FIFO;
                break;
         
        case FREEBSD_SCHED_RR:
-               *native_policy = SCHED_RR;
+               p = SCHED_RR;
                break;
 
        default:
-               error = EINVAL;
-               break;
+               return EINVAL;
        }
  
-       if (freebsd_params != NULL && native_params != NULL && !error) {
-               native_params = (struct sched_param *)freebsd_params;
+       if (native_policy != NULL)
+               *native_policy = p;
+
+       if (freebsd_params != NULL && native_params != NULL) {
+               /* XXX: Needs adjustment to do a proper conversion. */
+               native_params->sched_priority = freebsd_params->sched_priority;
        }
-        
-       return (error);
+       return 0;
 }
 
 /*
- * XXX: Needs adjustment to do a proper conversion.
  */
 static int
-sched_native2freebsd(int native_policy, struct sched_param *native_params,
+sched_native2freebsd(int native_policy, const struct sched_param *native_params,
     int *freebsd_policy, struct freebsd_sched_param *freebsd_params)
 {
-       int error;
-
-       error = 0;
+       int p;
 
        switch (native_policy) {
        case SCHED_OTHER:
-               *freebsd_policy = FREEBSD_SCHED_OTHER;
+               p = FREEBSD_SCHED_OTHER;
                break;
 
        case SCHED_FIFO:
-               *freebsd_policy = FREEBSD_SCHED_FIFO;
+               p = FREEBSD_SCHED_FIFO;
                break;
         
        case SCHED_RR:
-               *freebsd_policy = FREEBSD_SCHED_RR;
+               p = FREEBSD_SCHED_RR;
                break;
 
        default:
-               error = EINVAL;
-               break;
+               return EINVAL;
        }
  
-       if (native_params != NULL && freebsd_params != NULL && !error) {
-               freebsd_params = (struct freebsd_sched_param *)native_params;
+       if (freebsd_policy != NULL)
+               *freebsd_policy = p;
+
+       if (native_params != NULL && freebsd_params != NULL) {
+               /* XXX: Needs adjustment to do a proper conversion. */
+               freebsd_params->sched_priority = native_params->sched_priority;
        }
-        
-       return (error);
+
+       return 0;
 }
 
 int
@@ -199,7 +199,7 @@
                goto out;
 
  out:
-       return (error);
+       return error;
 }
 
 int



Home | Main Index | Thread Index | Old Index