Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Simplify the sysctl handlers.



details:   https://anonhg.NetBSD.org/src/rev/9f201a67aa55
branches:  trunk
changeset: 322893:9f201a67aa55
user:      maxv <maxv%NetBSD.org@localhost>
date:      Tue May 22 16:44:42 2018 +0000

description:
Simplify the sysctl handlers.

diffstat:

 sys/arch/x86/x86/spectre.c |  36 ++++++++----------------------------
 1 files changed, 8 insertions(+), 28 deletions(-)

diffs (64 lines):

diff -r 525387d0707f -r 9f201a67aa55 sys/arch/x86/x86/spectre.c
--- a/sys/arch/x86/x86/spectre.c        Tue May 22 16:36:19 2018 +0000
+++ b/sys/arch/x86/x86/spectre.c        Tue May 22 16:44:42 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spectre.c,v 1.16 2018/05/22 16:36:19 maxv Exp $        */
+/*     $NetBSD: spectre.c,v 1.17 2018/05/22 16:44:42 maxv Exp $        */
 
 /*
  * Copyright (c) 2018 NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.16 2018/05/22 16:36:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spectre.c,v 1.17 2018/05/22 16:44:42 maxv Exp $");
 
 #include "opt_spectre.h"
 
@@ -355,19 +355,9 @@
        if (error != 0 || newp == NULL)
                return error;
 
-       if (val == 0) {
-               if (!v2_mitigation_enabled)
-                       error = 0;
-               else
-                       error = mitigation_v2_change(false);
-       } else {
-               if (v2_mitigation_enabled)
-                       error = 0;
-               else
-                       error = mitigation_v2_change(true);
-       }
-
-       return error;
+       if (val == v2_mitigation_enabled)
+               return 0;
+       return mitigation_v2_change(val);
 }
 
 /* -------------------------------------------------------------------------- */
@@ -557,19 +547,9 @@
        if (error != 0 || newp == NULL)
                return error;
 
-       if (val == 0) {
-               if (!v4_mitigation_enabled)
-                       error = 0;
-               else
-                       error = mitigation_v4_change(false);
-       } else {
-               if (v4_mitigation_enabled)
-                       error = 0;
-               else
-                       error = mitigation_v4_change(true);
-       }
-
-       return error;
+       if (val == v4_mitigation_enabled)
+               return 0;
+       return mitigation_v4_change(val);
 }
 
 /* -------------------------------------------------------------------------- */



Home | Main Index | Thread Index | Old Index