summaryrefslogtreecommitdiff
path: root/sys/kern/kern_time.c
diff options
context:
space:
mode:
authorcheloha <cheloha@cvs.openbsd.org>2020-10-07 17:53:45 +0000
committercheloha <cheloha@cvs.openbsd.org>2020-10-07 17:53:45 +0000
commitdf9232fa06688b3ed1d85dca44bc1932ae00f0fa (patch)
tree990e045099d31693b24cc5845ec0dd15bd6efcf3 /sys/kern/kern_time.c
parent8df1478fdcb1c76cebd878532244ed82b13a860e (diff)
sys_getitimer(), sys_setitimer(): style(9), misc. cleanup
- Consolidate variable declarations. - Remove superfluous parentheses from return statements. - Prefer sizeof(variable) to sizeof(type) for copyin(9)/copyout(9). - Remove some intermediate pointers from sys_setitimer(). Using SCARG() directly here makes it more obvious to the reader what you're copying.
Diffstat (limited to 'sys/kern/kern_time.c')
-rw-r--r--sys/kern/kern_time.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 65c14bb1974..a2a78898369 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_time.c,v 1.143 2020/10/07 16:17:25 cheloha Exp $ */
+/* $OpenBSD: kern_time.c,v 1.144 2020/10/07 17:53:44 cheloha Exp $ */
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
/*
@@ -583,14 +583,14 @@ sys_getitimer(struct proc *p, void *v, register_t *retval)
int which;
which = SCARG(uap, which);
-
if (which < ITIMER_REAL || which > ITIMER_PROF)
- return (EINVAL);
+ return EINVAL;
+
memset(&aitv, 0, sizeof(aitv));
setitimer(which, NULL, &aitv);
- return (copyout(&aitv, SCARG(uap, itv), sizeof (struct itimerval)));
+ return copyout(&aitv, SCARG(uap, itv), sizeof(aitv));
}
int
@@ -601,42 +601,36 @@ sys_setitimer(struct proc *p, void *v, register_t *retval)
syscallarg(const struct itimerval *) itv;
syscallarg(struct itimerval *) oitv;
} */ *uap = v;
- struct itimerval aitv;
- struct itimerval olditv;
- const struct itimerval *itvp;
- struct itimerval *oitv;
+ struct itimerval aitv, olditv;
struct itimerval *newitvp, *olditvp;
- int error;
- int which;
+ int error, which;
which = SCARG(uap, which);
- oitv = SCARG(uap, oitv);
-
if (which < ITIMER_REAL || which > ITIMER_PROF)
- return (EINVAL);
+ return EINVAL;
+
newitvp = olditvp = NULL;
- itvp = SCARG(uap, itv);
- if (itvp) {
- error = copyin(itvp, &aitv, sizeof(struct itimerval));
+ if (SCARG(uap, itv) != NULL) {
+ error = copyin(SCARG(uap, itv), &aitv, sizeof(aitv));
if (error)
- return (error);
+ return error;
if (itimerfix(&aitv.it_value) || itimerfix(&aitv.it_interval))
- return (EINVAL);
+ return EINVAL;
newitvp = &aitv;
}
- if (oitv != NULL) {
+ if (SCARG(uap, oitv) != NULL) {
memset(&olditv, 0, sizeof(olditv));
olditvp = &olditv;
}
if (newitvp == NULL && olditvp == NULL)
- return (0);
+ return 0;
setitimer(which, newitvp, olditvp);
if (SCARG(uap, oitv) != NULL)
return copyout(&olditv, SCARG(uap, oitv), sizeof(olditv));
- return (0);
+ return 0;
}
/*