When cross-compiling the kernel using ports clang (tsk tsk), the
compiler reports the following:
src/sys/kern/kern_time.c:418:11: error: shifting a
negative signed value is undefined [-Werror,-Wshift-negative-value]
if (f < ADJFREQ_MIN || f > ADJFREQ_MAX)
^
src/sys/kern/kern_time.c:399:35: note: expanded from
macro 'ADJFREQ_MIN'
#define ADJFREQ_MIN (-500000000LL << 32)
~~~~~~~~~~~~ ^
Normally this does not occur because of the implicit -fwrapv option
with base clang. However, wouldn't it be better if the code avoided the
situation, for example by defining ADJFREQ_MIN as the negative
of ADJFREQ_MAX?
Index: kern/kern_time.c
===================================================================
RCS file: src/sys/kern/kern_time.c,v
retrieving revision 1.151
diff -u -p -r1.151 kern_time.c
--- kern/kern_time.c 23 Dec 2020 20:45:02 -0000 1.151
+++ kern/kern_time.c 30 May 2021 15:38:09 -0000
@@ -396,7 +396,7 @@ sys_settimeofday(struct proc *p, void *v
}
#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)