Print the "preposterous TOD clock time" message only if the RTC is

before very late 2020 (1/1/2021 minus a few leap days) instead of
late 1994.  Someone(TM) should remember to adjust this in somewhat
less than 26 years.
This commit is contained in:
simonb 2021-04-03 12:06:53 +00:00
parent 588b377eb0
commit 2beb587e3e

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_todr.c,v 1.46 2020/01/03 01:24:48 thorpej Exp $ */
/* $NetBSD: kern_todr.c,v 1.47 2021/04/03 12:06:53 simonb Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@ -70,7 +70,7 @@
#include "opt_todr.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.46 2020/01/03 01:24:48 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.47 2021/04/03 12:06:53 simonb Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -90,6 +90,9 @@ static kmutex_t todr_mutex;
static todr_chip_handle_t todr_handle;
static bool todr_initialized;
/* The minimum reasonable RTC date before preposterousness */
#define PREPOSTEROUS_YEARS (2021 - POSIX_BASE_YEAR)
/*
* todr_init:
* Initialize TOD clock data.
@ -213,7 +216,7 @@ todr_set_systime(time_t base)
if ((todr_handle == NULL) ||
(todr_gettime(todr_handle, &tv) != 0) ||
(tv.tv_sec < (25 * SECS_PER_COMMON_YEAR))) {
(tv.tv_sec < (PREPOSTEROUS_YEARS * SECS_PER_COMMON_YEAR))) {
if (todr_handle != NULL)
printf("WARNING: preposterous TOD clock time\n");