From c06ea86d3e9b1473fa4399cf3e4a6d797e641e21 Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Tue, 25 Jan 2022 04:04:42 +0000 Subject: Capture a repeated pattern into sysctl_securelevel_int function A few variables in the kernel are only writeable before securelevel is raised. It makes sense to handle them with less code. OK sthen@ bluhm@ --- sys/arch/amd64/amd64/machdep.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'sys/arch/amd64') diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c index 326f1c10253..08a20bf76ed 100644 --- a/sys/arch/amd64/amd64/machdep.c +++ b/sys/arch/amd64/amd64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.275 2021/10/06 15:46:03 claudio Exp $ */ +/* $OpenBSD: machdep.c,v 1.276 2022/01/25 04:04:40 gnezdo Exp $ */ /* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */ /*- @@ -513,12 +513,8 @@ cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case CPU_CPUVENDOR: return (sysctl_rdstring(oldp, oldlenp, newp, cpu_vendor)); case CPU_KBDRESET: - if (securelevel > 0) - return (sysctl_rdint(oldp, oldlenp, newp, - kbd_reset)); - else - return (sysctl_int(oldp, oldlenp, newp, newlen, - &kbd_reset)); + return (sysctl_securelevel_int(oldp, oldlenp, newp, newlen, + &kbd_reset)); case CPU_ALLOWAPERTURE: if (namelen != 1) return (ENOTDIR); /* overloaded */ -- cgit v1.2.3