From b9e7483a798ae4a21090f07a3cc474a7547c6d8f Mon Sep 17 00:00:00 2001 From: visa Date: Mon, 31 May 2021 12:45:33 +0000 Subject: [PATCH] Redefine ADJFREQ_MIN to avoid undefined behaviour (when not using -fwrapv) Change the definition of ADJFREQ_MIN so that it does not shift a negative value. Such shifting is undefined in standard C. This came up when cross-compiling the kernel using ports clang. The shifting becomes defined when compiling with option -fwrapv. Base clang enables this option by default. OK naddy@ cheloha@ --- sys/kern/kern_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c index aa380e0a525..37771cc02f0 100644 --- a/sys/kern/kern_time.c +++ b/sys/kern/kern_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_time.c,v 1.151 2020/12/23 20:45:02 cheloha Exp $ */ +/* $OpenBSD: kern_time.c,v 1.152 2021/05/31 12:45:33 visa Exp $ */ /* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */ /* @@ -396,7 +396,7 @@ sys_settimeofday(struct proc *p, void *v, register_t *retval) } #define ADJFREQ_MAX (500000000LL << 32) -#define ADJFREQ_MIN (-500000000LL << 32) +#define ADJFREQ_MIN (-ADJFREQ_MAX) int sys_adjfreq(struct proc *p, void *v, register_t *retval) -- 2.20.1